line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pithub::ResultSet; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PLU'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# Honestly stolen from Array::Iterator, removed all unused parts |
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
141
|
use strict; |
|
23
|
|
|
|
|
42
|
|
|
23
|
|
|
|
|
568
|
|
7
|
23
|
|
|
23
|
|
106
|
use warnings; |
|
23
|
|
|
|
|
45
|
|
|
23
|
|
|
|
|
6058
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01039'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
12
|
|
|
12
|
1
|
48
|
my ( $class, @array ) = @_; |
13
|
12
|
|
|
|
|
24
|
my $_array = $array[0]; |
14
|
12
|
|
|
|
|
68
|
my $iterator = { |
15
|
|
|
|
|
|
|
_current_index => 0, |
16
|
|
|
|
|
|
|
_length => 0, |
17
|
|
|
|
|
|
|
_iteratee => [], |
18
|
|
|
|
|
|
|
_iterated => 0, |
19
|
|
|
|
|
|
|
}; |
20
|
12
|
|
|
|
|
29
|
bless $iterator => $class; |
21
|
12
|
|
|
|
|
16
|
$iterator->_init( scalar @{$_array}, $_array ); |
|
12
|
|
|
|
|
54
|
|
22
|
12
|
|
|
|
|
204
|
return $iterator; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _init { |
26
|
12
|
|
|
12
|
|
37
|
my ( $self, $length, $iteratee ) = @_; |
27
|
12
|
|
|
|
|
39
|
$self->{_current_index} = 0; |
28
|
12
|
|
|
|
|
24
|
$self->{_length} = $length; |
29
|
12
|
|
|
|
|
27
|
$self->{_iteratee} = $iteratee; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _get_item { |
33
|
114
|
|
|
114
|
|
168
|
my ( $self, $iteratee, $index ) = @_; |
34
|
114
|
|
|
|
|
218
|
return $iteratee->[$index]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
## no critic (NamingConventions::Capitalization) |
38
|
|
|
|
|
|
|
sub getNext { |
39
|
124
|
|
|
124
|
1
|
713
|
my $self = shift; |
40
|
124
|
|
|
|
|
133
|
$self->{_iterated} = 1; |
41
|
124
|
100
|
|
|
|
226
|
$self->{_current_index} < $self->{_length} or return undef; |
42
|
114
|
|
|
|
|
181
|
return $self->_get_item( $self->{_iteratee}, $self->{_current_index}++ ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub getLength { |
46
|
2
|
|
|
2
|
1
|
23
|
my $self = shift; |
47
|
2
|
|
|
|
|
15
|
return $self->{_length}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=encoding UTF-8 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Pithub::ResultSet - Iterate over the results |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 VERSION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
version 0.01039 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SYNOPSIS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use Pithub::ResultSet (); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
see L |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Iterate over items in the result-set. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 B |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Constructor |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 B |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Get length of result-set. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 B |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Get next item in the result-set. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SEE ALSO |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over 4 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item B |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
H.Merijn Brand Ehmbrand@cpan.orgE |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 ORIGINAL AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Stevan Little Estevan@iinteractive.comE |
103
|
|
|
|
|
|
|
perlancar Eperlancar@cpan.orgE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Code derived from Array::Iterator, stripped down to only what is required |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Johannes Plunien |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Johannes Plunien. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
118
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |