MouseX::AttributeHelpers::Number
package Real; use Mouse; use MouseX::AttributeHelpers; has 'integer' => ( metaclass => 'Number', is => 'rw', isa => 'Int', default => 5, provides => { set => 'set', add => 'add', sub => 'sub', mul => 'mul', div => 'div', mod => 'mod', abs => 'abs', }, ); package main; my $real = Real->new; $real->add(5); # same as $real->integer($real->integer + 5); $real->sub(2); # same as $real->integer($real->integer - 2);
This provides a simple numeric attribute, which supports most of the basic math operations.
NAKAGAWA Masaki <masaki@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
MouseX::AttributeHelpers, MouseX::AttributeHelpers::Base
To install MouseX::AttributeHelpers, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MouseX::AttributeHelpers
CPAN shell
perl -MCPAN -e shell install MouseX::AttributeHelpers
For more information on module installation, please visit the detailed CPAN module installation guide.