Commit | Line | Data |
456a815d |
1 | package HTML::Zoom::CodeStream; |
2 | |
3 | use strict; |
4 | use warnings FATAL => 'all'; |
5f74b883 |
5 | use base qw(HTML::Zoom::StreamBase); |
456a815d |
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) = @_; |
d80786d0 |
17 | bless({ _code => $args->{code}, _zconfig => $args->{zconfig} }, $class); |
456a815d |
18 | } |
19 | |
20 | sub next { |
8f962884 |
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}->(); |
456a815d |
30 | } |
31 | |
32 | 1; |
33 | |