| 1 |
package XML::Feed::Content; |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
|
| 5 |
our $VERSION = '1.0.1'; |
| 6 |
|
| 7 |
use base qw( Class::ErrorHandler ); |
| 8 |
|
| 9 |
sub wrap { |
| 10 |
my $class = shift; |
| 11 |
my($c) = @_; |
| 12 |
bless { %$c }, $class; |
| 13 |
} |
| 14 |
*new = \&wrap; |
| 15 |
|
| 16 |
sub _var { |
| 17 |
my $content = shift; |
| 18 |
my $var = shift; |
| 19 |
$content->{$var} = shift if @_; |
| 20 |
$content->{$var}; |
| 21 |
} |
| 22 |
|
| 23 |
sub type { shift->_var('type', @_) } |
| 24 |
sub body { shift->_var('body', @_) } |
| 25 |
sub base { shift->_var('base', @_) } |
| 26 |
|
| 27 |
1; |
| 28 |
__END__ |
| 29 |
|
| 30 |
=head1 NAME |
| 31 |
|
| 32 |
XML::Feed::Content - Wrapper for content objects |
| 33 |
|
| 34 |
=head1 SYNOPSIS |
| 35 |
|
| 36 |
my $content = $entry->content; |
| 37 |
print $content->body; |
| 38 |
|
| 39 |
=head1 DESCRIPTION |
| 40 |
|
| 41 |
I<XML::Feed::Content> represents a content object in an I<XML::Feed::Entry> |
| 42 |
entry in a syndication feed. This could be a I<E<lt>descriptionE<gt>> |
| 43 |
element in an RSS feed, a I<E<lt>contentE<gt>> element in an Atom feed, |
| 44 |
etc. In other words, any element where knowing both the actual data and the |
| 45 |
B<type> of data is useful. |
| 46 |
|
| 47 |
=head1 USAGE |
| 48 |
|
| 49 |
=head2 wrap |
| 50 |
|
| 51 |
Take params and turn them into a I<XML::Feed::Content> object. |
| 52 |
|
| 53 |
=head2 new |
| 54 |
|
| 55 |
A synonym for I<wrap>. |
| 56 |
|
| 57 |
=head2 $content->body |
| 58 |
|
| 59 |
The actual data. |
| 60 |
|
| 61 |
=head2 $content->type |
| 62 |
|
| 63 |
The MIME type of the content in I<body>. |
| 64 |
|
| 65 |
This is really only useful in Atom feeds, because RSS feeds do not specify |
| 66 |
the type of content included in an entry. In RSS feeds, generally the MIME |
| 67 |
type defaults to I<text/html>. |
| 68 |
|
| 69 |
=head2 $content->base |
| 70 |
|
| 71 |
The url base of the content. |
| 72 |
|
| 73 |
=head1 AUTHOR & COPYRIGHT |
| 74 |
|
| 75 |
Please see the I<XML::Feed> manpage for author, copyright, and license |
| 76 |
information. |
| 77 |
|
| 78 |
=cut |