28c44c2de2644d4394b209be772860269a0549a3
[catagits/HTML-Zoom.git] / lib / HTML / Zoom / FlattenedStream.pm
1 package HTML::Zoom::FlattenedStream;
2
3 use strict;
4 use warnings FATAL => 'all';
5 use base qw(HTML::Zoom::StreamBase);
6
7 sub new {
8   my ($class, $args) = @_;
9   bless({ _source => $args->{source}, _zconfig => $args->{zconfig} }, $class);
10 }
11
12 sub next {
13   return unless (my $self = shift)->{_source};
14   my ($next, $s);
15   until (($next) = ($s = $self->{_cur}) ? $s->next : ()) {
16     unless (($self->{_cur}) = $self->{_source}->next) {
17       delete $self->{_source}; return;
18     }
19   }
20   return $next;
21 }
22
23 1;