blib/lib/CLDR/Number/Format/Percent.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 97.4% 38 / 39 CC 3 SCAR 4.1
CC
3
Cov
100%
__ANON__
2.0
format
2.0
BEGIN
1.0
CRAP 1.5
« blib/lib/CLDR/Number/Role/Base.pm ↑ Summary blib/lib/CLDR/Number/Format/Decimal.pm »
1 package CLDR::Number::Format::Percent;
2  
3 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 our $VERSION = '0.00_03';
7  
8 4 with qw( CLDR::Number::Role::Format );
9  
10 has permil => (
11 is => 'rw',
12 4 ▶ coerce => sub { $_[0] ? 1 : 0 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 2 2 4
13 4 default => 0,
14 );
15  
16 4 has percent_sign => (
17 is => 'rw',
18 );
19  
20 4 has permil_sign => (
21 is => 'rw',
22 );
23  
24 4 has _pattern_type => (
25 is => 'ro',
26 default => 'percent',
27 );
28  
29 after _trigger_locale => sub {
30 4 ▶ my ($self) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
31  
32 4 $self->_build_signs(qw{ percent_sign permil_sign });
33 4 };
34  
35 ▶sub BUILD {}
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
36  
37 sub format {
38 6 ▶ my ($self, $num) = @_;
Subroutine format: called CC=2 SCAR=6.9
Pod documented
39 6 my ($factor, $sign);
40  
41 6 ▶ if ($self->permil) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->permil) { } 3 3 6
42 3 $factor = 1_000;
43 3 $sign = $self->permil_sign;
44 }
45 else {
46 3 $factor = 100;
47 3 $sign = $self->percent_sign;
48 }
49  
50 6 my $format = $self->_format_number($num * $factor, $self->pattern);
51 6 $format =~ s{%}{$sign};
52  
53 6 return $format;
54 }
55  
56 4 1;
57  
58 __END__
« blib/lib/CLDR/Number/Role/Base.pm ↑ Summary blib/lib/CLDR/Number/Format/Decimal.pm »