File Coverage

blib/lib/Lego/Part/Image.pm
Criterion Covered Total %
statement 31 33 93.9
branch 4 4 100.0
condition 2 3 66.6
subroutine 9 9 100.0
pod 3 3 100.0
total 49 52 94.2


line stmt bran cond sub pod time code
1             package Lego::Part::Image;
2              
3             # Pragmas.
4 17     17   111917 use strict;
  17         35  
  17         422  
5 17     17   80 use warnings;
  17         37  
  17         479  
6              
7             # Modules.
8 17     17   6079 use Class::Utils qw(set_params);
  17         236713  
  17         554  
9 17     17   591 use Error::Pure qw(err);
  17         30  
  17         642  
10 17     17   82 use Readonly;
  17         33  
  17         678  
11 17     17   115 use Scalar::Util qw(blessed);
  17         30  
  17         4878  
12              
13             # Constants.
14             Readonly::Scalar our $EMPTY_STR => q{};
15              
16             # Version.
17             our $VERSION = 0.05;
18              
19             # Constructor.
20             sub new {
21 33     33 1 40234 my ($class, @params) = @_;
22              
23             # Create object.
24 33         77 my $self = bless {}, $class;
25              
26             # Part object.
27 33         102 $self->{'part'} = undef;
28              
29             # Process parameters.
30 33         112 set_params($self, @params);
31              
32             # Check part object.
33 25 100       267 if (! defined $self->{'part'}) {
34 4         15 err "Parameter 'part' is required.";
35             }
36 21 100 66     300 if (! blessed($self->{'part'})
37             || ! $self->{'part'}->isa('Lego::Part')) {
38              
39 8         179 err "Parameter 'part' must be Lego::Part object.";
40             }
41              
42             # Object.
43 13         58 return $self;
44             }
45              
46             # Get image.
47             sub image {
48 1     1 1 6 my $self = shift;
49             # TODO Implement getting of image with cache.
50 1         5 err "This is abstract class. image() method not implemented.";
51 0         0 return;
52             }
53              
54             # Get image URL.
55             sub image_url {
56 1     1 1 7 my $self = shift;
57 1         6 err "This is abstract class. image_url() method not implemented.";
58 0           return;
59             }
60              
61             1;
62              
63             __END__