| 1 | package WebService::OpenSky::Utils::Iterator; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | # ABSTRACT: Internal iterator class for WebService::OpenSky | ||||||||||||||
| 4 | |||||||||||||||
| 5 | 9 | ▶ | use WebService::OpenSky::Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 9 | ▶ | use WebService::OpenSky::Types qw( | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | ArrayRef | ||||||||||||||
| 8 | Defined | ||||||||||||||
| 9 | InstanceOf | ||||||||||||||
| 10 | PositiveOrZeroInt | ||||||||||||||
| 11 | 9 | ); | |||||||||||||
| 12 | |||||||||||||||
| 13 | 9 | our $VERSION = '0.5'; | |||||||||||||
| 14 | |||||||||||||||
| 15 | 9 | param rows => ( | |||||||||||||
| 16 | isa => ArrayRef [Defined], | ||||||||||||||
| 17 | reader => '_rows', | ||||||||||||||
| 18 | ); | ||||||||||||||
| 19 | |||||||||||||||
| 20 | 9 | field '_index' => ( | |||||||||||||
| 21 | writer => '_set_index', | ||||||||||||||
| 22 | isa => PositiveOrZeroInt, | ||||||||||||||
| 23 | default => 0, | ||||||||||||||
| 24 | ); | ||||||||||||||
| 25 | |||||||||||||||
| 26 | 8 | ▶ | method first() { | ||||||||||||
|
Subroutine
first: called CC=3 SCAR=11.3
Pod
documented
Branch: 2 branches
| |||||||||||||||
| 27 | 8 | return $self->_rows->[0]; | |||||||||||||
| 28 | 9 | } | |||||||||||||
| 29 | |||||||||||||||
| 30 | 44 | ▶ | method next() { ## no critic (Subroutines::ProhibitBuiltinHomonyms) | ||||||||||||
|
Subroutine
next: called CC=4 SCAR=14.0
Pod
documented
Branch: 2 branches
| |||||||||||||||
| 31 | 44 | my $i = $self->_index; | |||||||||||||
| 32 | 44 | ▶ | my $next = $self->_rows->[$i] or return; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 33 | 36 | $self->_set_index( $i + 1 ); | |||||||||||||
| 34 | 36 | return $next; | |||||||||||||
| 35 | 9 | } | |||||||||||||
| 36 | |||||||||||||||
| 37 | 1 | ▶ | method reset() { ## no critic (Subroutines::ProhibitBuiltinHomonyms) | ||||||||||||
|
Subroutine
reset: called CC=3 SCAR=11.2
Pod
documented
Branch: 2 branches
| |||||||||||||||
| 38 | 1 | $self->_set_index(0); | |||||||||||||
| 39 | 1 | return 1; | |||||||||||||
| 40 | 9 | } | |||||||||||||
| 41 | |||||||||||||||
| 42 | 14 | ▶ | method all() { | ||||||||||||
|
Subroutine
all: called CC=3 SCAR=11.2
Pod
documented
Branch: 2 branches
| |||||||||||||||
| 43 | 14 | return @{ $self->_rows }; | |||||||||||||
| 44 | 9 | } | |||||||||||||
| 45 | |||||||||||||||
| 46 | 13 | ▶ | method count() { | ||||||||||||
|
Subroutine
count: called CC=3 SCAR=11.2
Pod
documented
Branch: 2 branches
| |||||||||||||||
| 47 | 13 | my @all = $self->all; | |||||||||||||
| 48 | 13 | return scalar @all; | |||||||||||||
| 49 | } | ||||||||||||||
| 50 | |||||||||||||||
| 51 | __END__ | ||||||||||||||