line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lego::Part; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
3
|
|
|
3
|
|
32231
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
65
|
|
5
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
78
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Modules. |
8
|
3
|
|
|
3
|
|
1953
|
use Class::Utils qw(set_params); |
|
3
|
|
|
|
|
87833
|
|
|
3
|
|
|
|
|
59
|
|
9
|
3
|
|
|
3
|
|
184
|
use Error::Pure qw(err); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
773
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Version. |
12
|
|
|
|
|
|
|
our $VERSION = 0.02; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Constructor. |
15
|
|
|
|
|
|
|
sub new { |
16
|
0
|
|
|
0
|
1
|
|
my ($class, @params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Create object. |
19
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Color. |
22
|
0
|
|
|
|
|
|
$self->{'color'} = undef; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Lego design id. |
25
|
0
|
|
|
|
|
|
$self->{'design_id'} = undef; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Lego element id. |
28
|
0
|
|
|
|
|
|
$self->{'element_id'} = undef; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Process parameters. |
31
|
0
|
|
|
|
|
|
set_params($self, @params); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Check design id or element id. |
34
|
0
|
0
|
0
|
|
|
|
if (! defined $self->{'element_id'} |
35
|
|
|
|
|
|
|
&& ! defined $self->{'design_id'}) { |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
err "Parameter 'element_id' or 'design_id' is required."; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Object. |
41
|
0
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Get or set color. |
45
|
|
|
|
|
|
|
sub color { |
46
|
0
|
|
|
0
|
1
|
|
my ($self, $color) = @_; |
47
|
0
|
0
|
|
|
|
|
if ($color) { |
48
|
0
|
|
|
|
|
|
$self->{'color'} = $color; |
49
|
|
|
|
|
|
|
} |
50
|
0
|
|
|
|
|
|
return $self->{'color'}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Get or set lego design id. |
54
|
|
|
|
|
|
|
sub design_id { |
55
|
0
|
|
|
0
|
1
|
|
my ($self, $design_id) = @_; |
56
|
0
|
0
|
|
|
|
|
if ($design_id) { |
57
|
0
|
|
|
|
|
|
$self->{'design_id'} = $design_id; |
58
|
|
|
|
|
|
|
} |
59
|
0
|
|
|
|
|
|
return $self->{'design_id'}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Get or set lego element id. |
63
|
|
|
|
|
|
|
sub element_id { |
64
|
0
|
|
|
0
|
1
|
|
my ($self, $element_id) = @_; |
65
|
0
|
0
|
|
|
|
|
if ($element_id) { |
66
|
0
|
|
|
|
|
|
$self->{'element_id'} = $element_id; |
67
|
|
|
|
|
|
|
} |
68
|
0
|
|
|
|
|
|
return $self->{'element_id'}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |