File Coverage

blib/lib/Data/Enumerator/Limit.pm
Criterion Covered Total %
statement 21 21 100.0
branch 4 4 100.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Data::Enumerator::Limit;
2 3     3   19 use strict;
  3         5  
  3         107  
3 3     3   16 use warnings;
  3         6  
  3         85  
4 3     3   16 use base qw/Data::Enumerator::Base/;
  3         5  
  3         739  
5              
6              
7             sub iterator {
8 4     4 0 7 my ( $self ) = @_;
9 4         9 my ( $object, $offset, $limit ) = @{ $self->object };
  4         23  
10 4         23 my $object_iterator = $object->iterator;
11 4         13 my $current_offset = 0;
12 4         9 my $current_limit = 0;
13             return sub {
14 39     39   55 while (1) {
15 42         92 my $value = $object_iterator->();
16 42 100       264 next if ( $current_offset++ < $offset );
17 39 100       115 return $self->LAST if ( $current_limit++ >= $limit );
18 35         89 return $value;
19             }
20 4         21 };
21             }
22              
23             1;
24