File Coverage

blib/lib/Math/NumSeq/Base/IterateIth.pm
Criterion Covered Total %
statement 17 18 94.4
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 0 3 0.0
total 24 29 82.7


line stmt bran cond sub pod time code
1             # Copyright 2011, 2012, 2013, 2014 Kevin Ryde
2              
3             # This file is part of Math-NumSeq.
4             #
5             # Math-NumSeq is free software; you can redistribute it and/or modify
6             # it under the terms of the GNU General Public License as published by the
7             # Free Software Foundation; either version 3, or (at your option) any later
8             # version.
9             #
10             # Math-NumSeq is distributed in the hope that it will be useful, but
11             # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12             # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13             # for more details.
14             #
15             # You should have received a copy of the GNU General Public License along
16             # with Math-NumSeq. If not, see .
17              
18             package Math::NumSeq::Base::IterateIth;
19 20     20   410 use 5.004;
  20         66  
  20         813  
20 20     20   111 use strict;
  20         36  
  20         1300  
21              
22 20     20   178 use vars '$VERSION';
  20         44  
  20         4310  
23             $VERSION = 71;
24              
25             sub rewind {
26 339     339 0 197231 my ($self) = @_;
27 339         1598 $self->seek_to_i($self->i_start);
28             }
29             sub seek_to_i {
30 2018     2018 0 44471 my ($self, $i) = @_;
31 2018         5994 $self->{'i'} = $i;
32             }
33             sub next {
34 45760     45760 0 424126 my ($self) = @_;
35 45760         76377 my $i = $self->{'i'}++;
36 45760 50       122039 if (defined (my $value = $self->ith($i))) {
37 45760         3396131 return ($i, $value);
38             } else {
39 0           return;
40             }
41             }
42              
43             1;
44             __END__