| 1 | package Text::TokenStream::Token; | ||||||||||||
| 2 | |||||||||||||
| 3 | 3 | ▶ | use v5.12; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 3 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 3 | our $VERSION = '0.04'; | |||||||||||
| 7 | |||||||||||||
| 8 | 3 | ▶ | use Carp qw(confess); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 3 | ▶ | use Text::TokenStream::Types qw(Identifier Position); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 3 | ▶ | use Types::Standard qw(Bool HashRef Str); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 3 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 3 | has type => (is => 'ro', isa => Identifier, required => 1); | |||||||||||
| 15 | 3 | has text => (is => 'ro', isa => Str, required => 1); | |||||||||||
| 16 | 1 | ▶ | has captures => (is => 'ro', isa => HashRef[Str], default => sub { +{} }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | 3 | has cuddled => (is => 'ro', isa => Bool, default => 0); | |||||||||||
| 18 | 3 | has position => (is => 'ro', isa => Position, required => 1); | |||||||||||
| 19 | |||||||||||||
| 20 | 13 | ▶ | sub text_for_matching { shift->text } | ||||||||||
|
Subroutine
text_for_matching: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 21 | |||||||||||||
| 22 | 15 | ▶ | sub matches { | ||||||||||
|
Subroutine
matches: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 23 | 15 | my ($self, $target) = @_; | |||||||||||
| 24 | 15 | ▶ | return $self->text_for_matching eq $target if Str->check($target); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 3 | return !!grep $target->($_), $self; | |||||||||||
| 26 | } | ||||||||||||
| 27 | |||||||||||||
| 28 | 3 | ▶ | sub repr { | ||||||||||
|
Subroutine
repr: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 29 | 3 | my ($self, $indent) = @_; | |||||||||||
| 30 | |||||||||||||
| 31 | 3 | ▶ | return sprintf '%sToken type=%s position=%d cuddled=%d text=[%s]', | ||||||||||
|
Condition100%2/2
$indent // ""
MC/DC100%1/1
$indent // ""
$indent
Truth table100%2/2
A
A= $indent
| |||||||||||||
| 32 | $indent // '', $self->type, $self->position, $self->cuddled, $self->text; | ||||||||||||
| 33 | } | ||||||||||||
| 34 | |||||||||||||
| 35 | 3 | 1; | |||||||||||
| 36 | __END__ | ||||||||||||