File Coverage

blib/lib/XML/ASX/Entry.pm
Criterion Covered Total %
statement 46 54 85.1
branch 15 30 50.0
condition 2 6 33.3
subroutine 7 8 87.5
pod 0 4 0.0
total 70 102 68.6


line stmt bran cond sub pod time code
1             package XML::ASX::Entry;
2              
3 1     1   6 use strict;
  1         2  
  1         44  
4 1     1   5 use vars qw($VERSION $AUTOLOAD %ASX_SLOTS @ISA);
  1         3  
  1         109  
5              
6             @ISA = qw(XML::ASX);
7              
8 1     1   2044 use overload '""' => \&xml;
  1         1194  
  1         9  
9              
10             $VERSION = '0.01';
11              
12             my %RW_SLOTS = (
13             title => '',
14             moreinfo => '',
15             target => '',
16             duration => '',
17             copyright => '',
18             base => '',
19             author => '',
20             abstract => '',
21             clientskip => 'YES',
22              
23             duration => '00:00:00.00',
24             previewduration => '',
25             banner => '',
26             logo_icon => '',
27             logo_mark => '',
28             );
29              
30             sub AUTOLOAD {
31 29     29   38 my $self = shift;
32 29         38 my $param = $AUTOLOAD;
33 29         73 $param =~ s/.*:://;
34 29 50 33     78 die(__PACKAGE__." doesn't implement $param") unless defined($RW_SLOTS{$param}) or defined($ASX_SLOTS{$param});
35 29 100       102 $self->{$param} = shift if @_;
36 29         134 return $self->{$param};
37             }
38              
39             sub new {
40 1     1 0 2 my $class = shift;
41 1         2 my %param = @_;
42 1         2 my $self = bless {}, $class;
43              
44 1         4 $self->$_($ASX_SLOTS{$_}) foreach keys %ASX_SLOTS;
45 1         12 $self->$_($RW_SLOTS{$_}) foreach keys %RW_SLOTS;
46 1         3 $self->$_($param{$_}) foreach keys %param;
47              
48 1         5 return $self;
49             }
50              
51             sub add_ref {
52 0     0 0 0 my $self = shift;
53 0 0       0 push @{$self->{refs}}, shift if @_;
  0         0  
54 0         0 return $self->{refs}->[scalar @{$self->{refs}} - 1];
  0         0  
55             }
56              
57             sub each_ref {
58 1     1 0 2 my $self = shift;
59 1 50       5 return $self->{refs} ? @{$self->{refs}} : ();
  0         0  
60             }
61              
62             sub xml {
63 1     1 0 2 my $self = shift;
64              
65 1 50 33     4 die __PACKAGE__.': clientskip() must be "YES" or "NO"' if ($self->clientskip ne 'YES' and $self->clientskip ne 'NO');
66              
67 1         3 my $refstr = '';
68 1         8 foreach my $ref ($self->each_ref){
69 0         0 $refstr .= $self->entag('Ref','',{href=>$ref},1);
70             }
71              
72 1         3 my $paramstr = '';
73 1         6 my %param = $self->each_param;
74 1         3 foreach my $key (keys %param){
75 0         0 $paramstr .= $self->entag('PARAM','',{NAME=>$key,VALUE=>$param{$key}},1);
76             }
77              
78 1         2 my $bannercontent = '';
79 1 50       3 $bannercontent .= $self->entag('MoreInfo','',{href=>$self->moreinfo,target=>$self->target},1) if $self->moreinfo;
80 1 50       7 $bannercontent .= $self->entag('Abstract',$self->abstract) if $self->abstract;
81              
82 1         3 my $content = '';
83 1 50       4 $content .= $self->entag('Duration','',{value=>$self->duration},1) if $self->duration;
84 1 50       5 $content .= $self->entag('PreviewDuration','',{value=>$self->duration},1) if $self->previewduration;
85 1 50       9 $content .= $self->entag('Title',$self->title) if $self->title;
86 1 50       4 $content .= $self->entag('Copyright',$self->copyright) if $self->copyright;
87 1 50       4 $content .= $self->entag('Logo','',{href=>$self->logo_icon,Style=>'ICON'},1) if $self->logo_icon;
88 1 50       5 $content .= $self->entag('Logo','',{href=>$self->logo_mark,Style=>'MARK'},1) if $self->logo_mark;
89 1 50       4 $content .= $self->entag('MoreInfo','',{href=>$self->moreinfo,target=>$self->target},1) if $self->moreinfo;
90 1 50       4 $content .= $self->entag('Banner',$bannercontent,{href=>$self->banner}) if $self->banner;
91 1         1 $content .= $refstr;
92 1         2 $content .= $paramstr;
93 1         3 return $self->entag('Entry',
94             $content,
95             {ClientSkip => $self->clientskip},0
96             );
97             }
98              
99             1;
100             __END__