--- trunk/lib/WebPAC/Input/ISIS.pm 2005/07/16 17:14:43 9 +++ trunk/lib/WebPAC/Input/ISIS.pm 2005/07/16 20:35:30 10 @@ -197,18 +197,18 @@ return $self->{'max_mfn'} = $maxmfn; } -=head2 fetch_rec +=head2 fetch Fetch next record from database. It will also displays progress bar. - my $rec = $webpac->fetch_rec; + my $rec = $isis->fetch; -You should rearly have the need to call this function directly. Instead use -C which returns normalised data. +Record from this function should probably go to C for +normalisation. =cut -sub fetch_rec { +sub fetch { my $self = shift; my $log = $self->_get_logger(); @@ -238,33 +238,60 @@ } } -=head2 fetch_data_structure +=head2 pos -Fetch data structure of next record from database. +Returns current record number (MFN). + + print $isis->pos; - my @ds = $webpac->fetch_data_structure; +First record in database has position 1. =cut -sub fetch_data_structure { +sub pos { my $self = shift; + return $self->{'current_mfn'}; +} + + +=head2 size + +Returns number of records in database + + print $isis->size; + +=cut - return $self->data_structure( - $self->fetch_rec(@_) - ); +sub size { + my $self = shift; + return $self->{'max_mfn'}; } -=head2 mfn +=head2 seek -Returns current record number (MFN). +Seek to specified MFN in file. + + $isis->seek(42); - print $webpac->mfn; +First record in database has position 1. =cut -sub mfn { +sub seek { my $self = shift; - return $self->{'current_mfn'}; + my $pos = shift || return; + + my $log = $self->_get_logger(); + + if ($pos < 1) { + $log->warn("seek before first record"); + $pos = 1; + } elsif ($pos > $self->{'max_mfn'}) { + $log->warn("seek beyond last record"); + $pos = $self->{'max_mfn'}; + } + + return $self->{'current_mfn'} = (($pos - 1) || -1); } =head1 AUTHOR