File Coverage

blib/lib/Box/Calc/BoxType.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             package Box::Calc::BoxType;
2             $Box::Calc::BoxType::VERSION = '1.0206';
3 10     10   917 use strict;
  10         22  
  10         293  
4 10     10   49 use warnings;
  10         19  
  10         392  
5 10     10   534 use Moose;
  10         452202  
  10         53  
6             with 'Box::Calc::Role::Container';
7             with 'Box::Calc::Role::Mailable';
8 10     10   59391 use Ouch;
  10         1664  
  10         98  
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.0206
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             has name => (
71             is => 'ro',
72             isa => 'Str',
73             required => 1,
74             );
75              
76             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             my $self = shift;
93             return $self->weight * 0.7;
94             }
95             );
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     14 1 20 my $self = shift;
105             return {
106 14         277 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 10     10   2404 no Moose;
  10         22  
  10         55  
117             __PACKAGE__->meta->make_immutable;