line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- Perl -*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# instances of this object hold a list of choices that are all rendered |
4
|
|
|
|
|
|
|
# together as a string |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Lingua::Awkwords::ListOf; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
110295
|
use strict; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
103
|
|
9
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
128
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
1828
|
use Moo; |
|
4
|
|
|
|
|
38177
|
|
|
4
|
|
|
|
|
18
|
|
12
|
4
|
|
|
4
|
|
6415
|
use namespace::clean; |
|
4
|
|
|
|
|
38219
|
|
|
4
|
|
|
|
|
25
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has filters => ( |
17
|
|
|
|
|
|
|
is => 'rwp', |
18
|
|
|
|
|
|
|
default => sub { [] }, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
has filter_with => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
default => sub { '' }, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
has terms => ( |
25
|
|
|
|
|
|
|
is => 'rwp', |
26
|
|
|
|
|
|
|
default => sub { [] }, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
######################################################################## |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
# METHODS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub add { |
34
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
35
|
1
|
|
|
|
|
1
|
push @{ $self->terms }, @_; |
|
1
|
|
|
|
|
4
|
|
36
|
1
|
|
|
|
|
2
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
7
|
|
|
7
|
1
|
14
|
sub add_filters { my $self = shift; push @{ $self->filters }, @_; return $self } |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
26
|
|
|
7
|
|
|
|
|
15
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub render { |
42
|
80
|
|
|
80
|
1
|
1178
|
my ($self) = @_; |
43
|
|
|
|
|
|
|
|
44
|
80
|
|
|
|
|
110
|
my $str = ''; |
45
|
80
|
|
|
|
|
99
|
for my $term ( @{ $self->terms } ) { |
|
80
|
|
|
|
|
176
|
|
46
|
103
|
|
|
|
|
230
|
$str .= $term->render; |
47
|
|
|
|
|
|
|
} |
48
|
80
|
|
50
|
|
|
448
|
my $filter_with = $self->filter_with // ''; |
49
|
80
|
|
|
|
|
91
|
for my $filter ( @{ $self->filters } ) { |
|
80
|
|
|
|
|
125
|
|
50
|
16
|
|
|
|
|
134
|
$str =~ s/\Q$filter/$filter_with/g; |
51
|
|
|
|
|
|
|
} |
52
|
80
|
|
|
|
|
256
|
return $str; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub walk { |
56
|
9
|
|
|
9
|
1
|
16
|
my ($self, $callback) = @_; |
57
|
9
|
|
|
|
|
17
|
$callback->($self); |
58
|
9
|
|
|
|
|
14
|
for my $term ( @{ $self->terms } ) { |
|
9
|
|
|
|
|
18
|
|
59
|
13
|
|
|
|
|
40
|
$term->walk($callback); |
60
|
|
|
|
|
|
|
} |
61
|
9
|
|
|
|
|
16
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |