X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FAutobox%2FNumber.pm;h=1dcbb08fc34c1489068490a2344907c3afc6d851;hb=a1f00ce9bc1114d8573e56079e46db8687a01602;hp=2c2f1a906b1fe8e7e0d4102653020e75cea07bcc;hpb=ea4e64bf393378b8e16896f6618a98fda24cb2fc;p=gitmo%2FMoose-Autobox.git diff --git a/lib/Moose/Autobox/Number.pm b/lib/Moose/Autobox/Number.pm index 2c2f1a9..1dcbb08 100644 --- a/lib/Moose/Autobox/Number.pm +++ b/lib/Moose/Autobox/Number.pm @@ -1,10 +1,15 @@ package Moose::Autobox::Number; use Moose::Role; -our $VERSION = '0.01'; +our $VERSION = '0.13'; with 'Moose::Autobox::Value'; - + +sub to { + return [ $_[0] .. $_[1] ] if $_[0] <= $_[1]; + return [ reverse $_[1] .. $_[0] ]; +} + 1; __END__ @@ -23,6 +28,21 @@ This is a role to describes a Numeric value. =over 4 +=item B + +Takes another number as argument and produces an array ranging from +the number the method is called on to the number given as argument. In +some situations, this method intentionally behaves different from the +range operator in perl: + + $foo = [ 5 .. 1 ]; # $foo is [] + + $foo = 5->to(1); # $foo is [ 5, 4, 3, 2, 1 ] + +=back + +=over 4 + =item B =back @@ -46,4 +66,4 @@ L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=cut \ No newline at end of file +=cut