File Coverage

blib/lib/Lego/Part/Image/BricklinkCom.pm
Criterion Covered Total %
statement 19 20 95.0
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 28 30 93.3


line stmt bran cond sub pod time code
1             package Lego::Part::Image::BricklinkCom;
2              
3 4     4   264175 use base qw(Lego::Part::Image);
  4         7  
  4         2176  
4 4     4   32 use strict;
  4         8  
  4         95  
5 4     4   21 use warnings;
  4         8  
  4         246  
6              
7 4     4   25 use Error::Pure qw(err);
  4         8  
  4         985  
8              
9             our $VERSION = 0.06;
10              
11             # Get image URL.
12             sub image_url {
13 2     2 1 13 my $self = shift;
14              
15 2 50       13 if (! defined $self->{'part'}->design_id) {
16 0         0 err "Design ID doesn't defined.";
17             }
18 2         21 my $url;
19 2 100       8 if (defined $self->{'part'}->color) {
20             $url = sprintf 'https://img.bricklink.com/ItemImage/PN/%s/%s.png',
21 1         11 $self->{'part'}->color, $self->{'part'}->design_id;
22             } else {
23             $url = sprintf 'https://img.bricklink.com/ItemImage/PL/%s.png',
24 1         13 $self->{'part'}->design_id;
25             }
26              
27 2         30 return $url;
28             }
29              
30             1;
31              
32             __END__