factor out ArrayStream, update new stream types to respect peek
[catagits/HTML-Zoom.git] / lib / HTML / Zoom / ArrayStream.pm
diff --git a/lib/HTML/Zoom/ArrayStream.pm b/lib/HTML/Zoom/ArrayStream.pm
new file mode 100644 (file)
index 0000000..7a7e05c
--- /dev/null
@@ -0,0 +1,21 @@
+package HTML::Zoom::ArrayStream;
+
+use strict;
+use warnings FATAL => 'all';
+use base qw(HTML::Zoom::StreamBase);
+
+sub new {
+  my ($class, $args) = @_;
+  bless(
+    { _zconfig => $args->{zconfig}, _array => [ @{$args->{array}} ] },
+    $class
+  );
+}
+
+sub _next {
+  my $ary = $_[0]->{_array};
+  return unless @$ary;
+  return shift @$ary;
+}
+
+1;