File Coverage

blib/lib/Math/NumSeq/Base/IterateIth.pm
Criterion Covered Total %
statement 16 17 94.1
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 0 3 0.0
total 23 28 82.1


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   267 use 5.004;
  20         41  
20 20     20   60 use strict;
  20         18  
  20         319  
21              
22 20     20   51 use vars '$VERSION';
  20         18  
  20         2498  
23             $VERSION = 72;
24              
25             sub rewind {
26 339     339 0 38276 my ($self) = @_;
27 339         1029 $self->seek_to_i($self->i_start);
28             }
29             sub seek_to_i {
30 2018     2018 0 22106 my ($self, $i) = @_;
31 2018         2870 $self->{'i'} = $i;
32             }
33             sub next {
34 45760     45760 0 197466 my ($self) = @_;
35 45760         35310 my $i = $self->{'i'}++;
36 45760 50       59514 if (defined (my $value = $self->ith($i))) {
37 45760         66127 return ($i, $value);
38             } else {
39 0           return;
40             }
41             }
42              
43             1;
44             __END__