| 1 | package HTML::Zoom::MappedStream; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 6 | ▶ | use strictures 1; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 6 | ▶ | use base qw(HTML::Zoom::StreamBase); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 18 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 7 | 18 | my ($class, $args) = @_; | |||||||||||||
| 8 | bless({ | ||||||||||||||
| 9 | _source => $args->{source}, _mapper => $args->{mapper}, | ||||||||||||||
| 10 | _zconfig => $args->{zconfig} | ||||||||||||||
| 11 | 18 | }, $class); | |||||||||||||
| 12 | } | ||||||||||||||
| 13 | |||||||||||||||
| 14 | 62 | ▶ | sub _next { | ||||||||||||
|
Subroutine
_next: called CC=5 SCAR=16.4
| |||||||||||||||
| 15 | 62 | my ($self, $am_peek) = @_; | |||||||||||||
| 16 | 62 | ▶ | return unless $self->{_source}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 17 | # If we were aiming for a "true" perl-like map then we should | ||||||||||||||
| 18 | # elegantly handle the case where the map function returns 0 events | ||||||||||||||
| 19 | # and the case where it returns >1 - if you're reading this comment | ||||||||||||||
| 20 | # because you wanted it to do that, now would be the time to fix it :) | ||||||||||||||
| 21 | 62 | ▶ | if (my ($next) = $self->{_source}->${\($am_peek ? 'peek' : 'next')}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 22 | 44 | ▶ | $self->{_peeked_from} = $next if $am_peek; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | 44 | local $_ = $next; | |||||||||||||
| 24 | 44 | return $self->{_mapper}->($next); | |||||||||||||
| 25 | } | ||||||||||||||
| 26 | 18 | delete $self->{_source}; | |||||||||||||
| 27 | return | ||||||||||||||
| 28 | 18 | } | |||||||||||||
| 29 | |||||||||||||||
| 30 | 6 | 1; | |||||||||||||