CLI/Value.pm

filter: Statementstmt 68.7% 11 / 16 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 3 / 3 totaltotal 65.3% 17 / 26 CC 2 SCAR 10.4
CC
2
Cov
61%
add
6.0
to_str_with_usd
2.0
BEGIN
1.0
CRAP 2.8
« CLI/Converter.pm ↑ Summary CLI/Fill.pm »
1 package Finance::CoinbasePro::API::CLI::Value;
2 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use Finance::CoinbasePro::API::CLI::Util::CurrencyUtil qw( format_currency format_crypto_with_usd );
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 has 'num' => (is=>'rw', isa=>"Num", required=>1 );
7 1 has 'currency' => (is=>'ro', isa=>"Str", required=>1 );
8 sub to_str {
9 2 ▶ my $self = shift;
Subroutine to_str: called CC=1 SCAR=0.0
Pod documented
10 2 return format_currency( $self->{num}, $self->{currency} );
11 }
12 sub to_str_with_usd {
13 0 ▶ my ($self, $per_usd) = @_; # $value, $per_usd_float
Subroutine to_str_with_usd: not called CC=1 SCAR=6.9
Pod documented
14 0 return format_crypto_with_usd( $self->{num}, $self->{currency}, $per_usd );
15 }
16 sub add {
17 0 ▶ my ($self, $v) = @_;
Subroutine add: not called CC=2 SCAR=17.9
Pod documented
18 0 ▶ die( "$0: can't add $self->{currency} (" . $self->to_str() . ") and $v->{currency}( " . $v->to_str() . "\n") unless ($self->currency eq $v->currency);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->currency eq $v->currency 0 0 0
19 0 $self->num( $self->num + $v->num );
20 }
21  
22 =for comment
23 sub subtract {
24 my ($self, $v) = @_;
25 die "$0: can't subtract $self->{currency} and $v->{currency}\n" unless ($self->currency eq $v->currency);
26 $self->num( $self->num - $v->num );
27 }
28 =cut
29  
30  
31 1 1;
32  
33  
34  
35  
36 #################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################
37  
38 =head1 NAME
39  
40 Finance::CoinbasePro::API::CLI::Value - stores a value and a currency
41  
42  
43 =head1 DESCRIPTION
44  
45 a tradable value - a number and a currency
46  
47  
48 =head1 REQUIRES
49  
50 L<Finance::CoinbasePro::API::CLI::Util::CurrencyUtil>
51  
52 L<Mouse>
53  
54  
55 =head1 METHODS
56  
57 =head2 add
58  
59 add();
60  
61 =head2 subtract
62  
63 subtract();
64  
65 =head2 to_str
66  
67 to_str();
68  
69 =head2 to_str_with_usd
70  
71 to_str_with_usd();
72  
73 =cut
74  
« CLI/Converter.pm ↑ Summary CLI/Fill.pm »