line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLDR::Number::Format::Percent; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
122
|
use v5.8.1; |
|
8
|
|
|
|
|
28
|
|
4
|
8
|
|
|
8
|
|
45
|
use utf8; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
71
|
|
5
|
8
|
|
|
8
|
|
189
|
use Carp; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
752
|
|
6
|
8
|
|
|
8
|
|
41
|
use CLDR::Number::Constant qw( $P ); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
931
|
|
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
40
|
use Moo; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
67
|
|
9
|
8
|
|
|
8
|
|
3145
|
use namespace::clean; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
78
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.16'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with qw( CLDR::Number::Role::Format ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has permil => ( |
16
|
|
|
|
|
|
|
is => 'rw', |
17
|
|
|
|
|
|
|
coerce => sub { $_[0] ? 1 : 0 }, |
18
|
|
|
|
|
|
|
default => 0, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has percent_sign => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has permil_sign => ( |
26
|
|
|
|
|
|
|
is => 'rw', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has _pattern_type => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
default => 'percent', |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
after _trigger_locale => sub { |
35
|
|
|
|
|
|
|
my ($self) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->_build_signs(qw{ percent_sign permil_sign }); |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub BUILD {} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub format { |
43
|
18
|
|
|
18
|
1
|
655
|
my ($self, $num) = @_; |
44
|
18
|
|
|
|
|
116
|
my ($factor, $sign); |
45
|
|
|
|
|
|
|
|
46
|
18
|
|
|
|
|
81
|
$num = $self->_validate_number(format => $num); |
47
|
18
|
100
|
|
|
|
95
|
return undef unless defined $num; |
48
|
|
|
|
|
|
|
|
49
|
17
|
100
|
|
|
|
259
|
if ($self->permil) { |
50
|
3
|
|
|
|
|
1067
|
$factor = 1_000; |
51
|
3
|
|
|
|
|
11
|
$sign = $self->permil_sign; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
14
|
|
|
|
|
3043
|
$factor = 100; |
55
|
14
|
|
|
|
|
50
|
$sign = $self->percent_sign; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
17
|
|
|
|
|
79
|
my $format = $self->_format_number($num * $factor); |
59
|
17
|
|
|
|
|
143
|
$format =~ s{$P}{$sign}; |
60
|
|
|
|
|
|
|
|
61
|
17
|
|
|
|
|
96
|
return $format; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |