NAME

WWW::Kickstarter::Iterator - Simple lazy lists

SYNOPSIS

use WWW::Kickstarter;

my $iter = WWW::Kickstarter::Iterator->new(\&fetcher);

while (my ($item) = $iter->get()) {
   ...
}

DESCRIPTION

Provides a means of iterating over Kickstarter results without doing more web queries than necessary.

CONSTRUCTOR

new

my $iter = WWW::Kickstarter::Iterator->new();
my $iter = WWW::Kickstarter::Iterator->new(\&generator);
my $iter = WWW::Kickstarter::Iterator->new(\&generator, \@pre_generated);

Creates a lazy list iterator.

$generator is a reference to a subroutine which generates the next item of the list. It may return more than one item if it is convenient for it to do so. Returning an empty list signifies the end of the list.

$generator may be undefined if the pre-generated items define the list in its entirety.

METHODS

get

my $done = my ($item) = $iter->get();
my $done = my @items = $iter->get($n);

Returns the next item in the list. If an argument is provided, returns that many items instead. If fewer than the requested number of items are are available, all remaining items are returned. If no more items are available, an empty list is returned.

get_rest

my @items = $iter->get_rest();

Returns the remaining items of the list, if any.

get_chunk

my $done = my @items = $iter->get_chunk();
my $done = my @items = $iter->get_chunk($min);

This method is similar get, except it will return extra items if it is cheap to do so (i.e. if they have already been generated). This is useful if you have an iterator with expensive an generator (such as every iterator returned by WWW::Kickstarter) and if you don't care exactly how many items you get back.

VERSION, BUGS, KNOWN ISSUES, DOCUMENTATION, SUPPORT, AUTHOR, COPYRIGHT AND LICENSE

See WWW::Kickstarter