line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AutoCode::Plurality; |
2
|
5
|
|
|
5
|
|
24
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
170
|
|
3
|
5
|
|
|
5
|
|
26
|
use AutoCode::Root; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
27
|
|
4
|
|
|
|
|
|
|
our @ISA=qw(AutoCode::Root); |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our %REGISTERED; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub add_plural { |
9
|
5
|
|
|
5
|
0
|
17
|
my ($class, $singular, $plural)=@_; |
10
|
5
|
|
|
|
|
34
|
$REGISTERED{$singular}=$plural; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub query_plural { |
14
|
10
|
|
|
10
|
0
|
18
|
my ($class, $singular)=@_; |
15
|
10
|
50
|
|
|
|
51
|
(exists $REGISTERED{$singular})?$REGISTERED{$singular}:"${singular}s"; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub plural_ref { |
19
|
0
|
|
|
0
|
0
|
|
my ($self, $singular)=@_; |
20
|
0
|
|
|
|
|
|
[$singular, $REGISTERED{$singular}]; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub plural_deref { |
24
|
0
|
|
|
0
|
0
|
|
my ($class, $accessor)=@_; |
25
|
0
|
0
|
|
|
|
|
(ref($accessor) eq 'ARRAY')? @$accessor: ($accessor, "${accessor}s"); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |