Sub::HandlesVia::HandlerLibrary::Number(3)

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

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_ceil' => 'ceil',
        'my_cmp' => 'cmp',
        'my_div' => 'div',
        'my_eq' => 'eq',
        'my_floor' => 'floor',
        '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',
      },
    );
  }

DESCRIPTION
This is a library of methods for Sub::HandlesVia.

DELEGATABLE METHODS

  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

  add( $addend )
Arguments: 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

  ceil()
Finds the ceiling of the current number, updating the attribute. Like "ceil" from builtin, but in-place.

  cmp( $num )
Arguments: Num.

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

  div( $divisor )
Arguments: 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

  eq( $num )
Arguments: Num.

Returns "$object->attr == $num".

  floor()
Finds the floor of the current number, updating the attribute. Like "floor" from builtin, but in-place.

  ge( $num )
Arguments: Num.

Returns "$object->attr >= $num".

  get()
Returns the current value of the number.

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

  gt( $num )
Arguments: Num.

Returns "$object->attr > $num".

  le( $num )
Arguments: Num.

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

  lt( $num )
Arguments: Num.

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

  mod( $divisor )
Arguments: 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

  mul( $factor )
Arguments: 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

  ne( $num )
Arguments: Num.

Returns "$object->attr != $num".

  set( $value )
Arguments: Num.

Sets the number to a new value.

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

  sub( $subtrahend )
Arguments: 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

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

SEE ALSO
Sub::HandlesVia.

AUTHOR
Toby Inkster <tobyink@cpan.org>.

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.

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.