| 1 | package Box::Calc::Item; | ||
| 2 | 14 | $Box::Calc::Item::VERSION = '1.0205'; | |
| 3 | 14 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 14 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 14 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 14 | with 'Box::Calc::Role::Dimensional'; | |
| 8 | |||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | Box::Calc::Item - The container class for the items you wish to pack. | ||
| 13 | |||
| 14 | =head1 VERSION | ||
| 15 | |||
| 16 | version 1.0205 | ||
| 17 | |||
| 18 | =head1 SYNOPSIS | ||
| 19 | |||
| 20 | my $item = Box::Calc::Item->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 width of your item. | ||
| 37 | |||
| 38 | =item y | ||
| 39 | |||
| 40 | The length of your item. | ||
| 41 | |||
| 42 | =item z | ||
| 43 | |||
| 44 | The thickness of your item. | ||
| 45 | |||
| 46 | =item weight | ||
| 47 | |||
| 48 | The weight of your item. | ||
| 49 | |||
| 50 | =item name | ||
| 51 | |||
| 52 | The name of your item. If you're referring it back to an external system you may wish to use this field to store you item ids instead of item names. | ||
| 53 | |||
| 54 | =back | ||
| 55 | |||
| 56 | =back | ||
| 57 | |||
| 58 | |||
| 59 | =head2 name | ||
| 60 | |||
| 61 | Returns the name of this item. | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | 14 | has name => ( | |
| 66 | is => 'ro', | ||
| 67 | isa => 'Str', | ||
| 68 | required => 1, | ||
| 69 | ); | ||
| 70 | |||
| 71 | =head2 describe | ||
| 72 | |||
| 73 | Returns all the important details about this item as a hash reference. | ||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | sub describe { | ||
| 78 | 20830 | ▶ | my $self = shift; |
|
Subroutine
describe: called CC=1 SCAR=0.0
Pod
documented
| |||
| 79 | return { | ||
| 80 | 20830 | name => $self->name, | |
| 81 | weight => $self->weight, | ||
| 82 | x => $self->x, | ||
| 83 | y => $self->y, | ||
| 84 | z => $self->z, | ||
| 85 | }; | ||
| 86 | } | ||
| 87 | |||
| 88 | =head1 ROLES | ||
| 89 | |||
| 90 | This class installs L<Box::Calc::Role::Dimensional>. | ||
| 91 | |||
| 92 | =cut | ||
| 93 | |||
| 94 | 14 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 95 | 14 | __PACKAGE__->meta->make_immutable; | |