line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::OpenSky::Utils::Iterator; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Internal iterator class for WebService::OpenSky |
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
171135
|
use WebService::OpenSky::Moose; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
67
|
|
6
|
9
|
|
|
|
|
179
|
use WebService::OpenSky::Types qw( |
7
|
|
|
|
|
|
|
ArrayRef |
8
|
|
|
|
|
|
|
Defined |
9
|
|
|
|
|
|
|
InstanceOf |
10
|
|
|
|
|
|
|
PositiveOrZeroInt |
11
|
9
|
|
|
9
|
|
331471
|
); |
|
9
|
|
|
|
|
1862
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.4'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
param rows => ( |
16
|
|
|
|
|
|
|
isa => ArrayRef [Defined], |
17
|
|
|
|
|
|
|
reader => '_rows', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
field '_index' => ( |
21
|
|
|
|
|
|
|
writer => '_set_index', |
22
|
|
|
|
|
|
|
isa => PositiveOrZeroInt, |
23
|
|
|
|
|
|
|
default => 0, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
8
|
50
|
|
8
|
1
|
31
|
method first() { |
|
8
|
50
|
|
|
|
24
|
|
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
10
|
|
27
|
8
|
|
|
|
|
34
|
return $self->_rows->[0]; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
44
|
50
|
|
44
|
1
|
4317
|
method next() { ## no critic (Subroutines::ProhibitBuiltinHomonyms) |
|
44
|
50
|
|
|
|
100
|
|
|
44
|
|
|
|
|
85
|
|
|
44
|
|
|
|
|
53
|
|
31
|
44
|
|
|
|
|
127
|
my $i = $self->_index; |
32
|
44
|
100
|
|
|
|
323
|
my $next = $self->_rows->[$i] or return; |
33
|
36
|
|
|
|
|
316
|
$self->_set_index( $i + 1 ); |
34
|
36
|
|
|
|
|
336
|
return $next; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
1
|
50
|
|
1
|
1
|
10
|
method reset() { ## no critic (Subroutines::ProhibitBuiltinHomonyms) |
|
1
|
50
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
38
|
1
|
|
|
|
|
5
|
$self->_set_index(0); |
39
|
1
|
|
|
|
|
10
|
return 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
14
|
50
|
|
14
|
1
|
54
|
method all() { |
|
14
|
50
|
|
|
|
107
|
|
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
23
|
|
43
|
14
|
|
|
|
|
27
|
return @{ $self->_rows }; |
|
14
|
|
|
|
|
71
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
13
|
50
|
|
13
|
1
|
1771
|
method count() { |
|
13
|
50
|
|
|
|
46
|
|
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
23
|
|
47
|
13
|
|
|
|
|
64
|
my @all = $self->all; |
48
|
13
|
|
|
|
|
178
|
return scalar @all; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding UTF-8 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
WebService::OpenSky::Utils::Iterator - Internal iterator class for WebService::OpenSky |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
version 0.4 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use WebService::OpenSky::Utils::Iterator; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $results = WebService::OpenSky::Utils::Iterator->new( rows => [ 1, 2, 3 ] ); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
while ( my $result = $results->next ) { |
72
|
|
|
|
|
|
|
... |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
A simple iterator class. To keep it dead simple, it only allows defined values |
78
|
|
|
|
|
|
|
to be passed in. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 METHODS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 C<next> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
while ( my $result = $results->next ) { |
85
|
|
|
|
|
|
|
... |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns the next member in the iterator. Returns C<undef> if the iterator is |
89
|
|
|
|
|
|
|
exhausted. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 C<count> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
if ( $results->count ) { |
94
|
|
|
|
|
|
|
... |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Returns the number of members in the iterator. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 C<first> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $object = $results->first; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Returns the first object in the results. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 C<reset> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$results->reset; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Resets the iterator to point to the first member. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 C<all> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my @objects = $results->all; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Returns a list of all members in the iterator. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Curtis "Ovid" Poe <curtis.poe@gmail.com> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This software is Copyright (c) 2023 by Curtis "Ovid" Poe. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This is free software, licensed under: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |