Box::Calc::Role::Dimensional - Role to add standard dimensions to objects.
=head1 VERSION
version 1.0206
=head2 SYNOPSIS
The x, y, and z attributes are first sorted from largest to smallest before creating the object. So you can insert them in any order. x=3, y=9, z=1 would become x=r9, y=3, z=1.
#----------#
| |
| |
| Y |
| |
| |
| X |
#----------#
Z is from bottom up
=head1 METHODS
This role installs these methods:
=head2 x
Returns the largest side of an object.
=cut
hasx=> (
is=> 'rw',
required=> 1,
isa=> 'Num',
);
=head2 y
Returns the middle side of an object.
=cut
hasy=> (
is=> 'rw',
required=> 1,
isa=> 'Num',
);
=head2 z
Returns the shortest side of an object.
=cut
hasz=> (
is=> 'rw',
required=> 1,
isa=> 'Num',
);
=head2 weight
Returns the weight of an object.
=cut
hasweight=> (
is=> 'ro',
isa=> 'Num',
required=> 1,
);
=head2 volume
Returns the result of multiplying x, y, and z.
=cut
subvolume {
my($self) = @_;
return$self->x * $self->y * $self->z;
}
=head2 dimensions
Returns an array reference containing x, y, and z.
=cut
subdimensions {
my($self) = @_;
return[ $self->x, $self->y, $self->z, ];
}
=head2 extent
Returns a string of C<x,y,z>. Good for comparing whether two items are dimensionally similar.