| 1 | package TaskPipe::Iterator_Array; | ||||||||||
| 2 | |||||||||||
| 3 | 38 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 38 | extends 'TaskPipe::Iterator'; | |||||||||
| 5 | 38 | with 'MooseX::ConfigCascade'; | |||||||||
| 6 | |||||||||||
| 7 | 38 | has array => (is => 'rw', isa => 'ArrayRef', required => 1); | |||||||||
| 8 | 38 | has array_pointer => (is => 'rw', isa => 'Int', default => 0); | |||||||||
| 9 | |||||||||||
| 10 | has 'next' => (is => 'rw', isa => 'CodeRef', lazy => 1, default => sub{ | ||||||||||
| 11 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=5.7
| |||||||||||
| 12 | return sub{ | ||||||||||
| 13 | 0 | ▶ | my $result; | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 14 | 0 | ▶ | if ( $self->array_pointer > $#{$self->array} ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 0 | $result = undef; | |||||||||
| 16 | } else { | ||||||||||
| 17 | 0 | $result = $self->array->[ $self->array_pointer ]; | |||||||||
| 18 | 0 | $self->array_pointer( $self->array_pointer + 1 ); | |||||||||
| 19 | } | ||||||||||
| 20 | 0 | return $result; | |||||||||
| 21 | } | ||||||||||
| 22 | 0 | }); | |||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | has 'reset' => (is => 'rw', isa => 'CodeRef', lazy => 1, default => sub{ | ||||||||||
| 26 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 27 | return sub{ | ||||||||||
| 28 | 0 | ▶ | my ($index) = @_; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 29 | 0 | $self->array_pointer( $index ); | |||||||||
| 30 | 0 | }; | |||||||||
| 31 | 38 | }); | |||||||||
| 32 | |||||||||||
| 33 | |||||||||||
| 34 | has 'count' => (is => 'rw', isa => 'CodeRef', lazy => 1, default => sub{ | ||||||||||
| 35 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 36 | return sub{ | ||||||||||
| 37 | 0 | ▶ | return +scalar @{$self->array}; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 38 | 0 | }; | |||||||||
| 39 | 38 | }); | |||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | 38 | 1; | |||||||||