File: Iterator.pm

package info (click to toggle)
libformvalidator-simple-perl 0.29-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 412 kB
  • sloc: perl: 3,043; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 565 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package FormValidator::Simple::Iterator;
use strict;

sub new {
    my $class = shift;
    my $self  = bless { }, $class;
    $self->_init(@_);
    return $self;
}

sub _init {
    my ($self, $records) = @_;
    $self->{_index}   = 0;
    $self->{_records} = $records;
}

sub reset {
    my $self = shift;
    $self->{_index} = 0;
}

sub next {
    my $self = shift;
    return unless ($self->{_records}->records_count > $self->{_index});
    my $record = $self->{_records}->get_record_at($self->{_index});
    $self->{_index}++;
    return $record;
}

1;
__END__