Box-Calc
view release on metacpan or search on metacpan
lib/Box/Calc.pm view on Meta::CPAN
"water bottle" => 2,
}
}
]
=cut
sub packing_list {
my $self = shift;
my @boxes;
foreach my $box (@{$self->boxes}) {
my ($weight, $list) = $box->packing_list;
push @boxes, {
id => $box->id,
name => $box->name,
weight => $weight,
packing_list => $list,
};
}
return \@boxes;
}
=head2 packing_instructions()
Returns a data structure with all the item names individually packed into rows, layers, and boxes. This can be used to build documentation on how to pack a set of boxes, and to generate a complete build history.
[
{ # box one
id => "xxx",
name => "big box",
layers => [
{ # layer one
rows => [
{ # row one
items => [
{ # item one
name => "apple",
...
},
...
],
},
...
],
...
},
],
},
]
=cut
sub packing_instructions {
my $self = shift;
my @boxes = map { $_->packing_instructions} @{ $self->boxes };
return \@boxes;
}
=head1 TODO
There are some additional optimizations that could be done to speed things up a bit. We might also be able to get a better fill percentage (less void space), although that's not really the intent of Box::Calc.
=head1 PREREQS
L<Moose>
L<Ouch>
L<Log::Any>
L<Data::GUID>
=head1 SUPPORT
=over
=item Repository
L<http://github.com/rizen/Box-Calc>
=item Bug Reports
L<http://github.com/rizen/Box-Calc/issues>
=back
=head1 SEE ALSO
Although these modules don't solve the same problem as this module, they may help you build something that does if Box::Calc doesn't quite help you do what you want.
=over
=item L<Algorithm::Knapsack>
=item L<Algorithm::Bucketizer>
=item L<Algorithm::Knap01DP>
=back
=head1 AUTHOR
=over
=item JT Smith <jt_at_plainblack_dot_com>
=item Colin Kuskie <colink_at_plainblack_dot_com>
=back
=head1 LEGAL
Box::Calc is Copyright 2012 Plain Black Corporation (L<http://www.plainblack.com>) and is licensed under the same terms as Perl itself.
=cut
no Moose;
__PACKAGE__->meta->make_immutable;
( run in 1.028 second using v1.01-cache-2.11-cpan-39bf76dae61 )