line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lego::Part; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
3
|
|
|
3
|
|
22126
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
91
|
|
5
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
75
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Modules. |
8
|
3
|
|
|
3
|
|
1310
|
use Class::Utils qw(set_params); |
|
3
|
|
|
|
|
56866
|
|
|
3
|
|
|
|
|
60
|
|
9
|
3
|
|
|
3
|
|
192
|
use Error::Pure qw(err); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
628
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Version. |
12
|
|
|
|
|
|
|
our $VERSION = 0.01; |
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__ |