package WWW::Extractor::Generic::Cursor;

use strict;
#use vars qw(@ISA);

#use WWW::Extractor::Generic::Object;

#@ISA = qw|WWW::Extractor::Generic::Object|;

#constructors:

sub new {
    my $class = shift;
    my $self = {
	index=>-1
    };
    return bless $self, $class;
}

sub next {
    my ($self, $list) = @_;
    $self->{index}++;
    $self->{index} = -1 if $self->{index} == $list->size;
    return ! $self->off;
}

sub prev {
    my ($self, $list) = @_;
    $self->{index} = $list->size if $self->{index} == -1;
    $self->{index}--;
    return ! $self->off;
}

sub off {
    my $self = shift;
    return $self->{index} == -1;
}

sub reset {
    my $self = shift;
    $self->{index} = -1;
}

sub as_string {
    my $self = shift;
    return "#$self->{index}";
}

1
