| 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 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 4 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 4 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 4 | our $VERSION = '0.10'; | |||||||||||
| 15 | |||||||||||||
| 16 | has filters => ( | ||||||||||||
| 17 | is => 'rwp', | ||||||||||||
| 18 | 55 | ▶ | default => sub { [] }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 4 | ); | |||||||||||
| 20 | has filter_with => ( | ||||||||||||
| 21 | is => 'rw', | ||||||||||||
| 22 | 55 | ▶ | default => sub { '' }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | 4 | ); | |||||||||||
| 24 | has terms => ( | ||||||||||||
| 25 | is => 'rwp', | ||||||||||||
| 26 | 0 | ▶ | default => sub { [] }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 27 | 4 | ); | |||||||||||
| 28 | |||||||||||||
| 29 | ######################################################################## | ||||||||||||
| 30 | # | ||||||||||||
| 31 | # METHODS | ||||||||||||
| 32 | |||||||||||||
| 33 | 1 | ▶ | sub add { | ||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 34 | 1 | my $self = shift; | |||||||||||
| 35 | 1 | push @{ $self->terms }, @_; | |||||||||||
| 36 | 1 | return $self; | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 7 | ▶ | sub add_filters { my $self = shift; push @{ $self->filters }, @_; return $self } | ||||||||||
|
Subroutine
add_filters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 40 | |||||||||||||
| 41 | 67 | ▶ | sub render { | ||||||||||
|
Subroutine
render: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 42 | 67 | my ($self) = @_; | |||||||||||
| 43 | |||||||||||||
| 44 | 67 | my $str = ''; | |||||||||||
| 45 | 67 | for my $term (@{ $self->terms }) { | |||||||||||
| 46 | 86 | $str .= $term->render; | |||||||||||
| 47 | } | ||||||||||||
| 48 | 67 | ▶ | my $filter_with = $self->filter_with // ''; | ||||||||||
|
Condition50%1/2
$self->filter_with // ""
MC/DC0%0/1
$self->filter_with // ""
$self->filter_with
Truth table50%1/2
A
A= $self->filter_with
| |||||||||||||
| 49 | 67 | for my $filter (@{ $self->filters }) { | |||||||||||
| 50 | 16 | $str =~ s/\Q$filter/$filter_with/g; | |||||||||||
| 51 | } | ||||||||||||
| 52 | 67 | return $str; | |||||||||||
| 53 | } | ||||||||||||
| 54 | |||||||||||||
| 55 | 9 | ▶ | sub walk { | ||||||||||
|
Subroutine
walk: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 56 | 9 | my ($self, $callback) = @_; | |||||||||||
| 57 | 9 | $callback->($self); | |||||||||||
| 58 | 9 | for my $term (@{ $self->terms }) { | |||||||||||
| 59 | 13 | $term->walk($callback); | |||||||||||
| 60 | } | ||||||||||||
| 61 | 9 | return; | |||||||||||
| 62 | } | ||||||||||||
| 63 | |||||||||||||
| 64 | 4 | 1; | |||||||||||
| 65 | __END__ | ||||||||||||