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
|
|
132169
|
use strict; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
106
|
|
9
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
89
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
1995
|
use Moo; |
|
4
|
|
|
|
|
44730
|
|
|
4
|
|
|
|
|
16
|
|
12
|
4
|
|
|
4
|
|
6827
|
use namespace::clean; |
|
4
|
|
|
|
|
40644
|
|
|
4
|
|
|
|
|
23
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
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
|
|
|
|
|
2
|
push @{ $self->terms }, @_; |
|
1
|
|
|
|
|
4
|
|
36
|
1
|
|
|
|
|
1
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
7
|
|
|
7
|
1
|
11
|
sub add_filters { my $self = shift; push @{ $self->filters }, @_; return $self } |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
25
|
|
|
7
|
|
|
|
|
17
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub render { |
42
|
67
|
|
|
67
|
1
|
1532
|
my ($self) = @_; |
43
|
|
|
|
|
|
|
|
44
|
67
|
|
|
|
|
91
|
my $str = ''; |
45
|
67
|
|
|
|
|
85
|
for my $term (@{ $self->terms }) { |
|
67
|
|
|
|
|
163
|
|
46
|
86
|
|
|
|
|
205
|
$str .= $term->render; |
47
|
|
|
|
|
|
|
} |
48
|
67
|
|
50
|
|
|
153
|
my $filter_with = $self->filter_with // ''; |
49
|
67
|
|
|
|
|
75
|
for my $filter (@{ $self->filters }) { |
|
67
|
|
|
|
|
107
|
|
50
|
16
|
|
|
|
|
139
|
$str =~ s/\Q$filter/$filter_with/g; |
51
|
|
|
|
|
|
|
} |
52
|
67
|
|
|
|
|
254
|
return $str; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub walk { |
56
|
9
|
|
|
9
|
1
|
19
|
my ($self, $callback) = @_; |
57
|
9
|
|
|
|
|
17
|
$callback->($self); |
58
|
9
|
|
|
|
|
17
|
for my $term (@{ $self->terms }) { |
|
9
|
|
|
|
|
17
|
|
59
|
13
|
|
|
|
|
31
|
$term->walk($callback); |
60
|
|
|
|
|
|
|
} |
61
|
9
|
|
|
|
|
18
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |