introduce ZConfig system, first cut at HTML::Zoom itself
[catagits/HTML-Zoom.git] / lib / HTML / Zoom / CodeStream.pm
1 package HTML::Zoom::CodeStream;
2
3 use strict;
4 use warnings FATAL => 'all';
5 use base qw(HTML::Zoom::StreamBase);
6
7 sub from_array {
8   my ($class, @array) = @_;
9   $class->new({ code => sub {
10     return unless @array;
11     return shift @array;
12   }});
13 }
14
15 sub new {
16   my ($class, $args) = @_;
17   bless({ _code => $args->{code}, _zconfig => $args->{zconfig} }, $class);
18 }
19
20 sub next {
21   my ($self) = @_;
22
23   # peeked entry so return that
24
25   if (exists $self->{_peeked}) {
26     return (delete $self->{_peeked});
27   }
28
29   $self->{_code}->();
30 }
31
32 1;
33