File Coverage

lib/Text/DHCPLeases/Object/Iterator.pm
Criterion Covered Total %
statement 23 25 92.0
branch n/a
condition 1 3 33.3
subroutine 7 8 87.5
pod n/a
total 31 36 86.1


line stmt bran cond sub pod time code
1             package DHCPLeases::Object::Iterator;
2              
3 1     1   5 use strict;
  1         1  
  1         40  
4 1     1   5 use warnings;
  1         2  
  1         32  
5 1     1   14 use vars qw($VERSION);
  1         1  
  1         310  
6             $VERSION = '1.0';
7              
8             =head1 NAME
9              
10             Text::DHCPLeases::Object::Iterator - Lease object iterator class
11              
12             =head1 SYNOPSIS
13              
14              
15             =head1 DESCRIPTION
16             =cut
17              
18              
19             sub new {
20 2     2   3 my ($proto, $list) = @_;
21 2   33     13 my $class = ref($proto) || $proto;
22 2         3 my $self = {};
23 2         8 $self->{_list} = $list;
24 2         4 $self->{_pos} = 0;
25 2         3 $self->{_size} = scalar @{$self->{_list}};
  2         5  
26 2         11 bless $self, $class;
27             }
28              
29 1     1   7 sub count { my ($self) = @_; return $self->{_size} };
  1         13  
30              
31             sub first {
32 1     1   3 my ($self) = @_;
33 1         30 return $self->{_list}->[0];
34             }
35              
36             sub last {
37 2     2   461 my ($self) = @_;
38 2         53 return $self->{_list}->[$self->{_size} - 1];
39             }
40              
41             sub next {
42 0     0     my ($self) = @_;
43 0           return $self->{_list}->[$self->{_pos}++];
44             }
45              
46             # Make sure to return 1
47             1;
48              
49              
50              
51             =head1 AUTHOR
52              
53             Carlos Vicente,
54              
55             =head1 LICENCE AND COPYRIGHT
56              
57             Copyright (c) 2012, Carlos Vicente . All rights reserved.
58              
59             This module is free software; you can redistribute it and/or
60             modify it under the same terms as Perl itself. See L.
61              
62              
63             =head1 DISCLAIMER OF WARRANTY
64              
65             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
66             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
67             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
68             PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
69             EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
70             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
71             ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
72             YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
73             NECESSARY SERVICING, REPAIR, OR CORRECTION.
74              
75             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
76             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
77             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
78             LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
79             OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
80             THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
81             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
82             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
83             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
84             SUCH DAMAGES.
85             =cut
86