File Coverage

lib/MP3/PodcastFetch/Feed/Channel.pm
Criterion Covered Total %
statement 15 15 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 21 24 87.5


line stmt bran cond sub pod time code
1             package MP3::PodcastFetch::Feed::Channel;
2              
3 1     1   5 use strict;
  1         2  
  1         33  
4 1     1   5 use warnings;
  1         2  
  1         25  
5 1     1   903 use Class::Struct;
  1         8252  
  1         7  
6              
7             =head1 NAME
8              
9             MP3::PodcastFetch::Feed::Channel -- Structure for recording Podcast channel information
10              
11             =head1 SYNOPSIS
12              
13             use MP3::PodcastFetch::Feed::Channel;
14             my $channel = MP3::PodcastFetch::Feed::Channel->new(title=>'my feed',
15             description =>'my very own feed'
16             );
17             my $title = $channel->title;
18             $channel->add_item($new_items);
19             my @items = $channel->items;
20              
21             =head1 DESCRIPTION
22              
23             This is a utility class for MP3::PodcastFetch that defines accessors
24             for various attributes of a Podcast Channel, including channel title,
25             description, author, and the list of podcast episodes currently
26             available.
27              
28             =head2 Accessors
29              
30             The following accessors are defined. They can be used to get and/or
31             fetch the current value:
32              
33             title Channel title
34             description Channel description
35             guid Channel unique ID
36             pubDate Channel publication date (in original format)
37             author Channel author
38             link Link to Channel URL
39             items List of MP3::PodcastFetch::Feed::Item objects corresponding to
40             podcast episodes currently available (read only accessor;
41             use add_item() to add new items).
42              
43             In addition, this class defines an add_item() method, which will add a
44             list of MP3::PodcastFetch::Feed::Item objects to the set of podcast
45             episodes.
46              
47             =cut
48              
49             struct (
50             'MP3::PodcastFetch::Feed::Channel' => {
51             title => '$',
52             description => '$',
53             guid => '$',
54             pubDate => '$',
55             author => '$',
56             link => '$',
57             duration => '$',
58             }
59             );
60              
61             sub add_item {
62 12     12 0 16 my $self = shift;
63 12         15 push @{$self->{'MP3::PodcastFetch::Feed::Channel::items'}},@_;
  12         75  
64             }
65              
66             sub items {
67 4     4 0 7 my $self = shift;
68 4 50       13 my $items = $self->{'MP3::PodcastFetch::Feed::Channel::items'} or return;
69 4         13 @$items;
70             }
71              
72             1;
73              
74             __END__