File Coverage

blib/lib/WWW/Discogs/HasMedia.pm
Criterion Covered Total %
statement 21 26 80.7
branch 2 4 50.0
condition 3 4 75.0
subroutine 6 7 85.7
pod 0 3 0.0
total 32 44 72.7


line stmt bran cond sub pod time code
1             package WWW::Discogs::HasMedia;
2              
3 6     6   39 use strict;
  6         10  
  6         195  
4 6     6   29 use warnings;
  6         12  
  6         155  
5 6     6   31 use Carp;
  6         12  
  6         1700  
6              
7             sub new {
8 1     1 0 1605 my ($class, @args) = @_;
9              
10 1 50       18 croak "Can't create abstract object WWW::Discogs::HasMedia"
11             if $class eq __PACKAGE__;
12             }
13              
14             sub _init {
15 4     4   9933 my ($self, %args) = @_;
16              
17 4   50     29 $self->{_images} = $args{images} || [];
18 4   100     25 $self->{_videos} = $args{videos} || [];
19              
20 4         21 return $self;
21             }
22              
23             sub images {
24 4     4 0 19831 my ($self, %args) = @_;
25 4         13 my $image_type = $args{type};
26              
27 4 50       20 if ($image_type) {
28 4         12 return grep { $_->{type} =~ /^${image_type}$/i } @{ $self->{_images} };
  13         152  
  4         15  
29             }
30              
31 0           return @{ $self->{_images} };
  0            
32             }
33              
34             sub videos {
35 0     0 0   my $self = shift;
36 0           return @{ $self->{_videos} };
  0            
37             }
38              
39             1;