X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FHTML%2FZoom%2FStreamBase.pm;h=e063c4843f7a4ce0b8de83db499dfea816d503da;hb=fdb039c6cede6d5cff55d27bde6afd723507cb81;hp=f81089f82188d7a010d6133f5bad8a765ba6bf6d;hpb=97192b02d221241de847e9fe853ec6867ee90fd0;p=catagits%2FHTML-Zoom.git diff --git a/lib/HTML/Zoom/StreamBase.pm b/lib/HTML/Zoom/StreamBase.pm index f81089f..e063c48 100644 --- a/lib/HTML/Zoom/StreamBase.pm +++ b/lib/HTML/Zoom/StreamBase.pm @@ -11,7 +11,7 @@ sub peek { if (exists $self->{_peeked}) { return ($self->{_peeked}); } - if (my ($peeked) = $self->_next) { + if (my ($peeked) = $self->_next(1)) { return ($self->{_peeked} = $peeked); } return; @@ -23,6 +23,9 @@ sub next { # peeked entry so return that if (exists $self->{_peeked}) { + if (my $peeked_from = delete $self->{_peeked_from}) { + $peeked_from->next; + } return (delete $self->{_peeked}); } @@ -68,10 +71,32 @@ sub select { }); } +sub then { + my ($self) = @_; + # see notes in HTML/Zoom.pm for why this needs to be fixed + $self->select($self->transform->selector); +} + sub apply { my ($self, $code) = @_; local $_ = $self; $self->$code; } +sub apply_if { + my ($self, $predicate, $code) = @_; + if($predicate) { + local $_ = $self; + $self->$code; + } + else { + $self; + } +} + +sub to_html { + my ($self) = @_; + $self->_zconfig->producer->html_from_stream($self); +} + 1;