Calc/BoxType.pm

filter: Statementstmt 100% 26 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 100% 34 / 34 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Calc/Role/Mailable.pm ↑ Summary Calc/Item.pm »
1 package Box::Calc::BoxType;
2 9 $Box::Calc::BoxType::VERSION = '1.0205';
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 with 'Box::Calc::Role::Container';
7 9 with 'Box::Calc::Role::Mailable';
8 9 ▶use Ouch;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 Box::Calc::BoxType - The container class for the types (sizes) of boxes that can be used for packing.
13  
14 =head1 VERSION
15  
16 version 1.0205
17  
18 =head1 SYNOPSIS
19  
20 my $item = Box::Calc::BoxType->new(name => 'Apple', x => 3, y => 3.3, z => 4, weight => 5 );
21  
22 =head1 METHODS
23  
24 =head2 new(params)
25  
26 Constructor.
27  
28 =over
29  
30 =item params
31  
32 =over
33  
34 =item x
35  
36 The interior width of your box.
37  
38 =item y
39  
40 The interior length of your box.
41  
42 =item z
43  
44 The interior thickness of your box.
45  
46 =item name
47  
48 The name of your box.
49  
50 =item weight
51  
52 The weight of your box.
53  
54 =back
55  
56 =back
57  
58 =head2 name
59  
60 Returns the name of this box.
61  
62  
63 =head2 category
64  
65 Returns the category name associated with this box type if any.
66  
67 =cut
68  
69  
70 9 has name => (
71 is => 'ro',
72 isa => 'Str',
73 required => 1,
74 );
75  
76 9 has category => (
77 is => 'ro',
78 isa => 'Str',
79 default => '',
80 );
81  
82 =head2 void_weight()
83  
84 Returns the weight assigned to the void space left in the box due to void space filler such as packing peanuts. Defaults to 70% of the box weight.
85  
86 =cut
87  
88 has void_weight => (
89 is => 'rw',
90 lazy => 1,
91 default => sub {
92 14 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
93 14 return $self->weight * 0.7;
94 }
95 9 );
96  
97 =head2 describe
98  
99 Returns a hash ref with the properties of this box type.
100  
101 =cut
102  
103 sub describe {
104 14 ▶ my $self = shift;
Subroutine describe: called CC=1 SCAR=0.0
Pod documented
105 return {
106 14 name => $self->name,
107 weight => $self->weight,
108 x => $self->x,
109 y => $self->y,
110 z => $self->z,
111 category=> $self->category,
112 };
113 }
114  
115  
116 9 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
117 9 __PACKAGE__->meta->make_immutable;
« Calc/Role/Mailable.pm ↑ Summary Calc/Item.pm »