| 1 | package Statistics::R::IO::ParserState; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Current state of the IO parser | ||||||||||||||||||||||||||||
| 3 | 15 | $Statistics::R::IO::ParserState::VERSION = '1.0002'; | |||||||||||||||||||||||||||
| 4 | 15 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use Class::Tiny::Antlers; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 15 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | has data => ( | ||||||||||||||||||||||||||||
| 10 | is => 'ro', | ||||||||||||||||||||||||||||
| 11 | 0 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 12 | 15 | ); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | has position => ( | ||||||||||||||||||||||||||||
| 15 | is => 'ro', | ||||||||||||||||||||||||||||
| 16 | 973 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 15 | ); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | has singletons => ( | ||||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||
| 21 | 973 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 15 | ); | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 284186 | ▶ | sub BUILDARGS { | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=6 SCAR=21.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 284186 | my $class = shift; | |||||||||||||||||||||||||||
| 27 | 284186 | my $attributes = {}; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 284186 | ▶ | if ( scalar @_ == 1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ( ref $_[0] eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | $attributes = $_[0] | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | else { | ||||||||||||||||||||||||||||
| 34 | 0 | $attributes->{name} = $_[0] | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | elsif ( @_ % 2 ) { | ||||||||||||||||||||||||||||
| 38 | 0 | die "The new() method for $class expects a hash reference or a key/value list." | |||||||||||||||||||||||||||
| 39 | . " You passed an odd number of arguments\n"; | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | else { | ||||||||||||||||||||||||||||
| 42 | 284186 | $attributes = { @_ }; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # split strings into a list of individual characters | ||||||||||||||||||||||||||||
| 46 | 284186 | ▶ | if (defined $attributes->{data} && !ref($attributes->{data})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $attributes->{"data"} and not ref $attributes->{"data"}
MC/DC50%1/2
defined $attributes->{"data"} and not ref $attributes->{"data"}
defined $attributes->{"data"}
not ref $attributes->{"data"}
Truth table66%2/3
A and not(B)
A= defined $attributes->{"data"}B= not ref $attributes->{"data"}
| |||||||||||||||||||||||||||||
| 47 | 981 | $attributes->{data} = [split //, $attributes->{data}]; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | $attributes | ||||||||||||||||||||||||||||
| 51 | 284186 | } | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 284186 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 284186 | my $self = shift; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 284186 | ▶ | die 'foo' unless ref($self->data) eq 'ARRAY' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 281234 | ▶ | sub at { | ||||||||||||||||||||||||||
|
Subroutine
at: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 281234 | my $self = shift; | |||||||||||||||||||||||||||
| 61 | 281234 | $self->data->[$self->position] | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 281262 | ▶ | sub next { | ||||||||||||||||||||||||||
|
Subroutine
next: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | 281262 | my $self = shift; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | ref($self)->new(data => $self->data, | ||||||||||||||||||||||||||||
| 68 | position => $self->position+1, | ||||||||||||||||||||||||||||
| 69 | 281262 | singletons => [ @{$self->singletons} ]) | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 1937 | ▶ | sub add_singleton { | ||||||||||||||||||||||||||
|
Subroutine
add_singleton: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 1937 | my ($self, $singleton) = (shift, shift); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 1937 | my @new_singletons = @{$self->singletons}; | |||||||||||||||||||||||||||
| 76 | 1937 | push @new_singletons, $singleton; | |||||||||||||||||||||||||||
| 77 | 1937 | ref($self)->new(data => $self->data, | |||||||||||||||||||||||||||
| 78 | position => $self->position, | ||||||||||||||||||||||||||||
| 79 | singletons => [ @new_singletons ]) | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1633 | ▶ | sub get_singleton { | ||||||||||||||||||||||||||
|
Subroutine
get_singleton: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 1633 | my ($self, $singleton_id) = (shift, shift); | |||||||||||||||||||||||||||
| 84 | 1633 | $self->singletons->[$singleton_id] | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 279805 | ▶ | sub eof { | ||||||||||||||||||||||||||
|
Subroutine
eof: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | 279805 | my $self = shift; | |||||||||||||||||||||||||||
| 89 | 279805 | $self->position >= scalar @{$self->data}; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 15 | 1; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | __END__ | ||||||||||||||||||||||||||||