line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lego::Part::Image; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
18
|
|
|
18
|
|
80198
|
use strict; |
|
18
|
|
|
|
|
27
|
|
|
18
|
|
|
|
|
528
|
|
5
|
18
|
|
|
18
|
|
61
|
use warnings; |
|
18
|
|
|
|
|
24
|
|
|
18
|
|
|
|
|
509
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Modules. |
8
|
18
|
|
|
18
|
|
5393
|
use Class::Utils qw(set_params); |
|
18
|
|
|
|
|
215962
|
|
|
18
|
|
|
|
|
447
|
|
9
|
18
|
|
|
18
|
|
830
|
use Error::Pure qw(err); |
|
18
|
|
|
|
|
25
|
|
|
18
|
|
|
|
|
574
|
|
10
|
18
|
|
|
18
|
|
69
|
use Readonly; |
|
18
|
|
|
|
|
23
|
|
|
18
|
|
|
|
|
564
|
|
11
|
18
|
|
|
18
|
|
70
|
use Scalar::Util qw(blessed); |
|
18
|
|
|
|
|
19
|
|
|
18
|
|
|
|
|
4104
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Constants. |
14
|
|
|
|
|
|
|
Readonly::Scalar our $EMPTY_STR => q{}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Version. |
17
|
|
|
|
|
|
|
our $VERSION = 0.02; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Constructor. |
20
|
|
|
|
|
|
|
sub new { |
21
|
26
|
|
|
26
|
1
|
21668
|
my ($class, @params) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Create object. |
24
|
26
|
|
|
|
|
64
|
my $self = bless {}, $class; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Part object. |
27
|
26
|
|
|
|
|
61
|
$self->{'part'} = undef; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Process parameters. |
30
|
26
|
|
|
|
|
76
|
set_params($self, @params); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Check part object. |
33
|
18
|
100
|
|
|
|
140
|
if (! defined $self->{'part'}) { |
34
|
4
|
|
|
|
|
12
|
err "Parameter 'part' is required."; |
35
|
|
|
|
|
|
|
} |
36
|
14
|
100
|
66
|
|
|
129
|
if (! blessed($self->{'part'}) |
37
|
|
|
|
|
|
|
|| ! $self->{'part'}->isa('Lego::Part')) { |
38
|
|
|
|
|
|
|
|
39
|
8
|
|
|
|
|
136
|
err "Parameter 'part' must be Lego::Part object."; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Object. |
43
|
6
|
|
|
|
|
18
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Get image. |
47
|
|
|
|
|
|
|
sub image { |
48
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
49
|
|
|
|
|
|
|
# TODO Implement getting of image with cache. |
50
|
1
|
|
|
|
|
4
|
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
|
5
|
my $self = shift; |
57
|
1
|
|
|
|
|
5
|
err "This is abstract class. image_url() method not implemented."; |
58
|
0
|
|
|
|
|
|
return; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |