line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Iterator.pm,v 1.14 2008/03/03 16:55:04 asc Exp $ |
2
|
1
|
|
|
1
|
|
1026
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
214
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Net::Delicious::Iterator; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$Net::Delicious::Iterator::VERSION = '1.14'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::Delicious::Iterator - iterator class for Net::Delicious thingies |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Net::Delicious::Iterator; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @dates = ({...},{...}); |
17
|
|
|
|
|
|
|
my $it = Net::Delicious::Iterator->new("Date",\@dates); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
while (my $d = $it->next()) { |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Do stuff with $d here |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Iterator class for Net::Delicious thingies |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NOTES |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
It isn't really expected that you will instantiate these |
31
|
|
|
|
|
|
|
objects outside of I itself. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 PACKAGE METHODS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 __PACKAGE__->new($foreign_class,\@data) |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Returns a I object. Woot! |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
0
|
|
|
0
|
1
|
|
my $pkg = shift; |
47
|
0
|
|
|
|
|
|
return bless {pkg=>$_[0], data=>$_[1], count=>0}, $pkg; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 $it->count() |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Return the number of available thingies. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub count { |
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
58
|
0
|
|
|
|
|
|
return scalar @{$self->{data}}; |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 $it->next() |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Returns the next object in the list of available thingies. Woot! |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub next { |
68
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
if (my $data = $self->{data}->[$self->{count}++]) { |
71
|
0
|
|
|
|
|
|
return $self->{pkg}->new($data); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub reset { |
76
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
77
|
0
|
|
|
|
|
|
$self->{count} = 0; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 VERSION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1.13 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DATE |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$Date: 2008/03/03 16:55:04 $ |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Aaron Straup Cope |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SEE ALSO |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 LICENSE |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Copyright (c) 2004-2008 Aaron Straup Cope. All rights reserved. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This is free software, you may use it and distribute it under the |
102
|
|
|
|
|
|
|
same terms as Perl itself. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return 1; |