Perl/Role/Number.pm

filter: Statementstmt 100% 27 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 7 / 7 totaltotal 100% 43 / 43 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
new
1.0
CRAP 1.0
« Perl/Role/Code.pm ↑ Summary Perl/String.pm »
1 package Data::Perl::Role::Number;
2 9 $Data::Perl::Role::Number::VERSION = '0.002011';
3 # ABSTRACT: Wrapping class for Perl scalar numbers.
4  
5 9 ▶use strictures 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶sub new { bless \(my $n = $_[1]), $_[0] }
Subroutine new: called CC=1 SCAR=0.0
Pod documented
10  
11 1 ▶sub add { ${$_[0]} = ${$_[0]} + $_[1] }
Subroutine add: called CC=1 SCAR=0.0
Pod documented
12  
13 1 ▶sub sub { ${$_[0]} = ${$_[0]} - $_[1] }
Subroutine sub: called CC=1 SCAR=0.0
Pod documented
14  
15 1 ▶sub mul { ${$_[0]} = ${$_[0]} * $_[1] }
Subroutine mul: called CC=1 SCAR=0.0
Pod documented
16  
17 1 ▶sub div { ${$_[0]} = ${$_[0]} / $_[1] }
Subroutine div: called CC=1 SCAR=0.0
Pod documented
18  
19 1 ▶sub mod { ${$_[0]} = ${$_[0]} % $_[1] }
Subroutine mod: called CC=1 SCAR=0.0
Pod documented
20  
21 1 ▶sub abs { ${$_[0]} = abs(${$_[0]}) }
Subroutine abs: called CC=1 SCAR=0.0
Pod documented
22  
23 9 1;
24  
25 =pod
26  
27 =encoding UTF-8
28  
29 =head1 NAME
30  
31 Data::Perl::Role::Number - Wrapping class for Perl scalar numbers.
32  
33 =head1 VERSION
34  
35 version 0.002011
36  
37 =head1 SYNOPSIS
38  
39 use Data::Perl qw/number/;
40  
41 my $num = number(123);
42  
43 $num->add(5); # $num == 128
44  
45 $num->div(2); # $num == 64
46  
47 =head1 DESCRIPTION
48  
49 This class provides a wrapper and methods for interacting with scalar strings.
50  
51 =head1 PROVIDED METHODS
52  
53 All of these methods modify the attribute's value in place. All methods return
54 the new value.
55  
56 =over 4
57  
58 =item B<new($value)>
59  
60 Constructs a new Data::Perl::Collection::Number object initialized with the passed
61 in value, and returns it.
62  
63 =item B<add($value)>
64  
65 Adds the current value of the attribute to C<$value>.
66  
67 =item B<sub($value)>
68  
69 Subtracts C<$value> from the current value of the attribute.
70  
71 =item B<mul($value)>
72  
73 Multiplies the current value of the attribute by C<$value>.
74  
75 =item B<div($value)>
76  
77 Divides the current value of the attribute by C<$value>.
78  
79 =item B<mod($value)>
80  
81 Returns the current value of the attribute modulo C<$value>.
82  
83 =item B<abs>
84  
85 Sets the current value of the attribute to its absolute value.
86  
87 =back
88  
89 =head1 SEE ALSO
90  
91 =over 4
92  
93 =item * L<Data::Perl>
94  
95 =item * L<MooX::HandlesVia>
96  
97 =back
98  
99 =head1 AUTHOR
100  
101 Matthew Phillips <mattp@cpan.org>
102  
103 =head1 COPYRIGHT AND LICENSE
104  
105 This software is copyright (c) 2020 by Matthew Phillips <mattp@cpan.org>.
106  
107 This is free software; you can redistribute it and/or modify it under
108 the same terms as the Perl 5 programming language system itself.
109  
110 =cut
111  
112 __END__
« Perl/Role/Code.pm ↑ Summary Perl/String.pm »