| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Box::Calc::Role::Container; |
|
2
|
|
|
|
|
|
|
$Box::Calc::Role::Container::VERSION = '1.0201'; |
|
3
|
10
|
|
|
10
|
|
5931
|
use strict; |
|
|
10
|
|
|
|
|
24
|
|
|
|
10
|
|
|
|
|
288
|
|
|
4
|
10
|
|
|
10
|
|
59
|
use warnings; |
|
|
10
|
|
|
|
|
22
|
|
|
|
10
|
|
|
|
|
238
|
|
|
5
|
10
|
|
|
10
|
|
3037
|
use Moose::Role; |
|
|
10
|
|
|
|
|
34353
|
|
|
|
10
|
|
|
|
|
122
|
|
|
6
|
|
|
|
|
|
|
with 'Box::Calc::Role::Dimensional'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Box::Calc::Role::Container - Extends the L<Box::Calc::Role::Dimensional> role to include outer dimensions. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
version 1.0201 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This role installs these methods: |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 outer_x |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Returns the outside dimension of largest side of an object. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has outer_x => ( |
|
28
|
|
|
|
|
|
|
is => 'rw', |
|
29
|
|
|
|
|
|
|
isa => 'Num', |
|
30
|
|
|
|
|
|
|
required => 1, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 outer_y |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Returns the outside dimension of the middle side of an object. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has outer_y => ( |
|
40
|
|
|
|
|
|
|
is => 'rw', |
|
41
|
|
|
|
|
|
|
isa => 'Num', |
|
42
|
|
|
|
|
|
|
required => 1, |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 outer_z |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Returns the outside dimension of the shortest side of an object. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has outer_z => ( |
|
52
|
|
|
|
|
|
|
is => 'rw', |
|
53
|
|
|
|
|
|
|
isa => 'Num', |
|
54
|
|
|
|
|
|
|
required => 1, |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 outer_volume |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns the result of multiplying outer_x, outer_y, and outer_z. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has outer_volume => ( |
|
64
|
|
|
|
|
|
|
is => 'ro', |
|
65
|
|
|
|
|
|
|
isa => 'Num', |
|
66
|
|
|
|
|
|
|
required => 1, |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 outer_dimensions |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns an array reference containing outer_x, outer_y, and outer_z. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has outer_dimensions => ( |
|
76
|
|
|
|
|
|
|
is => 'ro', |
|
77
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
78
|
|
|
|
|
|
|
required => 1, |
|
79
|
|
|
|
|
|
|
); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 outer_extent |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Returns a string of C<outer_x,outer_y,outer_z>. Good for comparing whether two items are dimensionally similar. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
has outer_extent => ( |
|
88
|
|
|
|
|
|
|
is => 'ro', |
|
89
|
|
|
|
|
|
|
isa => 'Str', |
|
90
|
|
|
|
|
|
|
required => 1, |
|
91
|
|
|
|
|
|
|
); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 max_weight |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
The max weight of the items including the container. Defaults to 1000. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
has max_weight => ( |
|
100
|
|
|
|
|
|
|
is => 'ro', |
|
101
|
|
|
|
|
|
|
isa => 'Num', |
|
102
|
|
|
|
|
|
|
default => 1000, |
|
103
|
|
|
|
|
|
|
); |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
106
|
|
|
|
|
|
|
my $orig = shift; |
|
107
|
|
|
|
|
|
|
my $className = shift; |
|
108
|
|
|
|
|
|
|
my $args; |
|
109
|
|
|
|
|
|
|
if (ref $_[0] eq 'HASH') { |
|
110
|
|
|
|
|
|
|
$args = shift; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
else { |
|
113
|
|
|
|
|
|
|
$args = { @_ }; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$args->{outer_x} ||= $args->{x}; |
|
117
|
|
|
|
|
|
|
$args->{outer_y} ||= $args->{y}; |
|
118
|
|
|
|
|
|
|
$args->{outer_z} ||= $args->{z}; |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# sort large to small |
|
121
|
|
|
|
|
|
|
my ( $x, $y, $z ) = sort { $b <=> $a } ( $args->{outer_x}, $args->{outer_y}, $args->{outer_z} ); |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$args->{outer_x} = $x; |
|
124
|
|
|
|
|
|
|
$args->{outer_y} = $y; |
|
125
|
|
|
|
|
|
|
$args->{outer_z} = $z; |
|
126
|
|
|
|
|
|
|
$args->{outer_volume} = $x * $y * $z; |
|
127
|
|
|
|
|
|
|
$args->{outer_dimensions} = [$x, $y, $z]; |
|
128
|
|
|
|
|
|
|
$args->{outer_extent} = join(',', $x, $y, $z); |
|
129
|
|
|
|
|
|
|
return $className->$orig($args); |
|
130
|
|
|
|
|
|
|
}; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |