=head1 NAME

Sub::HandlesVia::HandlerLibrary::Number - library of number-related methods

=head1 SYNOPSIS

  package My::Class {
    use Moo;
    use Sub::HandlesVia;
    use Types::Standard 'Num';
    has attr => (
      is => 'rwp',
      isa => Num,
      handles_via => 'Number',
      handles => {
        'my_abs' => 'abs',
        'my_add' => 'add',
        'my_cmp' => 'cmp',
        'my_div' => 'div',
        'my_eq' => 'eq',
        'my_ge' => 'ge',
        'my_get' => 'get',
        'my_gt' => 'gt',
        'my_le' => 'le',
        'my_lt' => 'lt',
        'my_mod' => 'mod',
        'my_mul' => 'mul',
        'my_ne' => 'ne',
        'my_set' => 'set',
        'my_sub' => 'sub',
      },
    );
  }

=head1 DESCRIPTION

This is a library of methods for L<Sub::HandlesVia>.

=head1 DELEGATABLE METHODS

=head2 C<< abs() >>

Finds the absolute value of the current number, updating the attribute.

  my $object = My::Class->new( attr => -5 );
  $object->my_abs;
  say $object->attr; ## ==> 5

=head2 C<< add( $addend ) >>

Arguments: B<< Num >>.

Adds a number to the existing number, updating the attribute.

  my $object = My::Class->new( attr => 4 );
  $object->my_add( 5 );
  say $object->attr; ## ==> 9

=head2 C<< cmp( $num ) >>

Arguments: B<< Num >>.

Returns C<< $object->attr <=> $num >>.

=head2 C<< div( $divisor ) >>

Arguments: B<< Num >>.

Divides the existing number by a number, updating the attribute.

  my $object = My::Class->new( attr => 6 );
  $object->my_div( 2 );
  say $object->attr; ## ==> 3

=head2 C<< eq( $num ) >>

Arguments: B<< Num >>.

Returns C<< $object->attr == $num >>.

=head2 C<< ge( $num ) >>

Arguments: B<< Num >>.

Returns C<< $object->attr >= $num >>.

=head2 C<< get() >>

Returns the current value of the number.

  my $object = My::Class->new( attr => 4 );
  say $object->my_get; ## ==> 4

=head2 C<< gt( $num ) >>

Arguments: B<< Num >>.

Returns C<< $object->attr > $num >>.

=head2 C<< le( $num ) >>

Arguments: B<< Num >>.

Returns C<< $object->attr <= $num >>.

=head2 C<< lt( $num ) >>

Arguments: B<< Num >>.

Returns C<< $object->attr < $num >>.

=head2 C<< mod( $divisor ) >>

Arguments: B<< Num >>.

Finds the current number modulo a divisor, updating the attribute.

  my $object = My::Class->new( attr => 5 );
  $object->my_mod( 2 );
  say $object->attr; ## ==> 1

=head2 C<< mul( $factor ) >>

Arguments: B<< Num >>.

Multiplies the existing number by a number, updating the attribute.

  my $object = My::Class->new( attr => 2 );
  $object->my_mul( 5 );
  say $object->attr; ## ==> 10

=head2 C<< ne( $num ) >>

Arguments: B<< Num >>.

Returns C<< $object->attr != $num >>.

=head2 C<< set( $value ) >>

Arguments: B<< Num >>.

Sets the number to a new value.

  my $object = My::Class->new( attr => 4 );
  $object->my_set( 5 );
  say $object->attr; ## ==> 5

=head2 C<< sub( $subtrahend ) >>

Arguments: B<< Num >>.

Subtracts a number from the existing number, updating the attribute.

  my $object = My::Class->new( attr => 9 );
  $object->my_sub( 6 );
  say $object->attr; ## ==> 3

=head1 BUGS

Please report any bugs to
L<https://github.com/tobyink/p5-sub-handlesvia/issues>.

=head1 SEE ALSO

L<Sub::HandlesVia>.

=head1 AUTHOR

Toby Inkster E<lt>tobyink@cpan.orgE<gt>.

=head1 COPYRIGHT AND LICENCE

This software is copyright (c) 2020, 2022 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=head1 DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

