line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Meta::Attribute::Native::Trait::Number; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2205'; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
1117
|
use Moose::Role; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
14
|
|
5
|
|
|
|
|
|
|
with 'Moose::Meta::Attribute::Native::Trait'; |
6
|
|
|
|
|
|
|
|
7
|
84
|
|
|
84
|
|
454
|
sub _helper_type { 'Num' } |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
16
|
no Moose::Role; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
8
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
1; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Helper trait for Num attributes |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__END__ |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=pod |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=encoding UTF-8 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Moose::Meta::Attribute::Native::Trait::Number - Helper trait for Num attributes |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 VERSION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
version 2.2205 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
package Real; |
32
|
|
|
|
|
|
|
use Moose; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'integer' => ( |
35
|
|
|
|
|
|
|
traits => ['Number'], |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
isa => 'Num', |
38
|
|
|
|
|
|
|
default => 5, |
39
|
|
|
|
|
|
|
handles => { |
40
|
|
|
|
|
|
|
set => 'set', |
41
|
|
|
|
|
|
|
add => 'add', |
42
|
|
|
|
|
|
|
sub => 'sub', |
43
|
|
|
|
|
|
|
mul => 'mul', |
44
|
|
|
|
|
|
|
div => 'div', |
45
|
|
|
|
|
|
|
mod => 'mod', |
46
|
|
|
|
|
|
|
abs => 'abs', |
47
|
|
|
|
|
|
|
}, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $real = Real->new(); |
51
|
|
|
|
|
|
|
$real->add(5); # same as $real->integer($real->integer + 5); |
52
|
|
|
|
|
|
|
$real->sub(2); # same as $real->integer($real->integer - 2); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This trait provides native delegation methods for numbers. All of the |
57
|
|
|
|
|
|
|
operations correspond to arithmetic operations like addition or |
58
|
|
|
|
|
|
|
multiplication. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DEFAULT TYPE |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
If you don't provide an C<isa> value for your attribute, it will default to |
63
|
|
|
|
|
|
|
C<Num>. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 PROVIDED METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
All of these methods modify the attribute's value in place. All methods return |
68
|
|
|
|
|
|
|
the new value. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over 4 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * B<add($value)> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Adds the current value of the attribute to C<$value>. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item * B<sub($value)> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Subtracts C<$value> from the current value of the attribute. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item * B<mul($value)> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Multiplies the current value of the attribute by C<$value>. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * B<div($value)> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Divides the current value of the attribute by C<$value>. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * B<mod($value)> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns the current value of the attribute modulo C<$value>. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * B<abs> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Sets the current value of the attribute to its absolute value. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 BUGS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
See L<Moose/BUGS> for details on reporting bugs. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHORS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over 4 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Jesse Luehrs <doy@cpan.org> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Shawn M Moore <sartak@cpan.org> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Hans Dieter Pearcey <hdp@cpan.org> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Chris Prather <chris@prather.org> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Matt S Trout <mstrout@cpan.org> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=back |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This software is copyright (c) 2006 by Infinity Interactive, Inc. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
153
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |