1MouseX::NativeTraits::NUusme(r3)Contributed Perl DocumenMtoautsieoXn::NativeTraits::Num(3)
2
3
4

NAME

6       MouseX::NativeTraits::Num - Helper trait for Num attributes
7

SYNOPSIS

9         package Real;
10         use Mouse;
11
12         has 'integer' => (
13             traits    => ['Number'],
14             is        => 'ro',
15             isa       => 'Num',
16             default   => 5,
17             handles   => {
18                 set => 'set',
19                 add => 'add',
20                 sub => 'sub',
21                 mul => 'mul',
22                 div => 'div',
23                 mod => 'mod',
24                 abs => 'abs',
25             },
26         );
27
28         my $real = Real->new();
29         $real->add(5); # same as $real->integer($real->integer + 5);
30         $real->sub(2); # same as $real->integer($real->integer - 2);
31

DESCRIPTION

33       This provides a simple numeric attribute, which supports most of the
34       basic math operations.
35

PROVIDED METHODS

37       It is important to note that all those methods do in place modification
38       of the value stored in the attribute. These methods are implemented
39       within this package.
40
41       add($value)
42           Adds the current value of the attribute to $value.
43
44       sub($value)
45           Subtracts $value from the current value of the attribute.
46
47       mul($value)
48           Multiplies the current value of the attribute by $value.
49
50       div($value)
51           Divides the current value of the attribute by $value.
52
53       mod($value)
54           Returns the current value of the attribute modulo $value.
55
56       abs Sets the current value of the attribute to its absolute value.
57

METHODS

59       meta
60       method_provider_class
61       helper_type
62

SEE ALSO

64       MouseX::NativeTraits
65
66
67
68perl v5.36.0                      2023-01-20      MouseX::NativeTraits::Num(3)
Impressum