File Coverage

blib/lib/WebService/IMDB/Trailer.pm
Criterion Covered Total %
statement 35 35 100.0
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod n/a
total 43 44 97.7


line stmt bran cond sub pod time code
1             # $Id: Trailer.pm 7370 2012-04-09 01:17:33Z chris $
2              
3             =head1 NAME
4              
5             WebService::IMDB::Trailer
6              
7             =cut
8              
9             package WebService::IMDB::Trailer;
10              
11 2     2   12 use strict;
  2         5  
  2         71  
12 2     2   11 use warnings;
  2         3  
  2         93  
13              
14             our $VERSION = '0.05';
15              
16 2     2   12 use base qw(Class::Accessor);
  2         13  
  2         207  
17              
18 2     2   13 use Carp;
  2         3  
  2         176  
19             our @CARP_NOT = qw(WebService::IMDB WebService::IMDB::Title);
20              
21 2     2   1291 use WebService::IMDB::Encoding;
  2         6  
  2         16  
22 2     2   61 use WebService::IMDB::Image;
  2         4  
  2         17  
23              
24             __PACKAGE__->mk_accessors(qw(
25             content_type
26             description
27             duration
28             encodings
29             slates
30             title
31             type
32             ));
33              
34              
35             =head1 METHODS
36              
37             =head2 content_type
38              
39             =head2 description
40              
41             =head2 duration
42              
43             =head2 encodings
44              
45             =head2 slates
46              
47             =head2 title
48              
49             =head2 type
50              
51             =cut
52              
53             sub _new {
54 1     1   3 my $class = shift;
55 1         3 my $ws = shift;
56 1 50       7 my $data = shift or die;
57              
58 1         4 my $self = {};
59              
60 1         4 bless $self, $class;
61              
62 1         8 $self->content_type($data->{'content_type'});
63 1         33 $self->description($data->{'description'});
64 1         26 $self->duration( DateTime::Duration->new('seconds' => $data->{'duration_seconds'}) );
65 1         123 $self->encodings( { map { $_ => WebService::IMDB::Encoding->_new($ws, $data->{'encodings'}->{$_} ) } keys %{$data->{'encodings'}}} );
  3         19  
  1         7  
66 1         11 $self->slates( [ map { WebService::IMDB::Image->_new($ws, $_) } @{$data->{'slates'}} ] );
  1         11  
  1         4  
67 1         23 $self->title($data->{'title'});
68 1         16 $self->type($data->{'@type'});
69              
70 1         16 return $self;
71             }
72              
73             1;