line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Ru::Pluralize; |
2
|
1
|
|
|
1
|
|
392
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
4
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
20
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
5
|
use parent 'DTL::Fast::Filter::Pluralize'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{pluralize} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
|
|
|
|
|
|
sub parse_parameters |
11
|
|
|
|
|
|
|
{ |
12
|
11
|
|
|
11
|
0
|
20
|
my $self = shift; |
13
|
2
|
|
|
|
|
22
|
push @{$self->{parameter}}, DTL::Fast::Variable->new('""') # specify suffix for one, two and five |
14
|
11
|
100
|
|
|
|
48
|
if (not scalar @{$self->{parameter}}); |
|
11
|
|
|
|
|
33
|
|
15
|
11
|
|
|
|
|
22
|
$self->{suffix} = $self->{parameter}->[0]; |
16
|
11
|
|
|
|
|
33
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub pluralize |
20
|
|
|
|
|
|
|
{ |
21
|
11
|
|
|
11
|
0
|
20
|
my $self = shift; |
22
|
11
|
|
|
|
|
25
|
my $value = shift; |
23
|
11
|
|
|
|
|
15
|
my $suffix = shift; |
24
|
|
|
|
|
|
|
|
25
|
11
|
|
100
|
|
|
32
|
my $suffix_one = shift @$suffix // ''; |
26
|
11
|
|
100
|
|
|
29
|
my $suffix_two = shift @$suffix // ''; |
27
|
11
|
|
100
|
|
|
30
|
my $suffix_five = shift @$suffix // $suffix_two; |
28
|
|
|
|
|
|
|
|
29
|
11
|
|
|
|
|
29
|
my $last_digit = substr int($value), - 1; |
30
|
11
|
|
|
|
|
16
|
my $amount = abs $value; |
31
|
|
|
|
|
|
|
|
32
|
11
|
100
|
100
|
|
|
61
|
if ($amount >= 10 and $amount <= 20) { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
33
|
1
|
|
|
|
|
2
|
$value = $suffix_five; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif ($last_digit == 1) { |
36
|
3
|
|
|
|
|
6
|
$value = $suffix_one; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif ($last_digit >= 2 and $last_digit <= 4) { |
39
|
4
|
|
|
|
|
8
|
$value = $suffix_two; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
3
|
|
|
|
|
7
|
$value = $suffix_five; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
11
|
|
|
|
|
39
|
return $value; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |