TiVo/Show.pm

filter: Statementstmt 97.5% 39 / 40 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 94.2% 49 / 52 CC 4 SCAR 8.5
CC
4
Cov
95%
new
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« TiVo/Folder.pm ↑ Summary
1 # $Id: Show.pm 57 2007-01-12 19:26:09Z boumenot $
2 # Author: Christopher Boumenot <boumenot@gmail.com>
3 ######################################################################
4 #
5 # Copyright 2006-2007 by Christopher Boumenot. This program is free
6 # software; you can redistribute it and/or modify it under the same
7 # terms as Perl itself.
8 #
9 ######################################################################
10  
11 package Net::TiVo::Show;
12  
13 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use base qw(Net::TiVo::Folder);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 4 ▶use Text::Wrap;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # Should be read as a poor man's XPath
20 4 our %DEFAULT_ATTRIBUTES_XPATH = (
21 station => [qw(Details SourceStation)],
22 name => [qw(Details Title)],
23 episode => [qw(Details EpisodeTitle)],
24 episode_num => [qw(Details EpisodeNumber)],
25 content_type => [qw(Details ContentType)],
26 capture_date => [qw(Details CaptureDate)],
27 format => [qw(Details SourceFormat)],
28 high_definition => [qw(Details HighDefinition)],
29 in_progress => [qw(Details InProgress)],
30 size => [qw(Details SourceSize)],
31 channel => [qw(Details SourceChannel)],
32 duration => [qw(Details Duration)],
33 description => [qw(Details Description)],
34 series_id => [qw(Details SeriesId)],
35 program_id => [qw(Details ProgramId)],
36 url => [qw(Links Content Url)],
37 );
38  
39 4 __PACKAGE__->make_accessor($_) for keys %DEFAULT_ATTRIBUTES_XPATH;
40 4 __PACKAGE__->make_accessor($_) for qw(tuner);
41  
42 8 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod undocumented
43 8 my ($class, %options) = @_;
44
45 8 ▶ unless ($options{xmlref}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($options{"xmlref"}) 0 8 8
46 0 die __PACKAGE__ . ": Mandatory param xmlref missing\n";
47 }
48  
49 8 my $self = {
50 %options,
51 };
52  
53 8 bless $self, $class;
54  
55 8 for my $attr (keys %DEFAULT_ATTRIBUTES_XPATH) {
56 128 my $value = __PACKAGE__->walk_hash_ref($options{xmlref}, $DEFAULT_ATTRIBUTES_XPATH{$attr});
57 128 $self->$attr($value);
58 }
59  
60 # do a little post processing
61 8 $self->capture_date(hex($self->capture_date()));
62  
63 8 my ($channel, $tuner) = split(/\-/, $self->channel());
64 8 ▶ $tuner = 0 unless defined $tuner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tuner 2 6 8
65 8 $self->channel($channel);
66 8 $self->tuner($tuner);
67  
68 8 return $self;
69 }
70  
71 1 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
72 1 my $self = shift;
73  
74 1 $Text::Wrap::columns = 72;
75  
76 1 my @a;
77 1 push @a, $self->name();
78 1 push @a, $self->episode();
79 1 push @a, $self->description();
80 1 push @a, int(($self->duration() / (60 * 1000)) + 0.5) . " min";
81  
82 1 my $s = wrap("", " ", join(", ", @a));
83 1 $s .= "\n ".$self->url();
84  
85 1 return $s;
86 }
87  
88 4 1;
89  
90 __END__
« TiVo/Folder.pm ↑ Summary