/[webpac2]/trunk/lib/WebPAC/Input/ISIS.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Input/ISIS.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6 by dpavlin, Sat Jul 16 14:44:38 2005 UTC revision 10 by dpavlin, Sat Jul 16 20:35:30 2005 UTC
# Line 5  use strict; Line 5  use strict;
5    
6  use WebPAC::Common;  use WebPAC::Common;
7  use base qw/WebPAC::Input WebPAC::Common/;  use base qw/WebPAC::Input WebPAC::Common/;
8    use Text::Iconv;
9    
10  =head1 NAME  =head1 NAME
11    
# Line 196  sub open { Line 197  sub open {
197          return $self->{'max_mfn'} = $maxmfn;          return $self->{'max_mfn'} = $maxmfn;
198  }  }
199    
200  =head2 fetch_rec  =head2 fetch
201    
202  Fetch next record from database. It will also displays progress bar.  Fetch next record from database. It will also displays progress bar.
203    
204   my $rec = $webpac->fetch_rec;   my $rec = $isis->fetch;
205    
206    Record from this function should probably go to C<data_structure> for
207    normalisation.
208    
209  =cut  =cut
210    
211  sub fetch_rec {  sub fetch {
212          my $self = shift;          my $self = shift;
213    
214          my $log = $self->_get_logger();          my $log = $self->_get_logger();
# Line 234  sub fetch_rec { Line 238  sub fetch_rec {
238          }          }
239  }  }
240    
241  =head2 mfn  =head2 pos
242    
243  Returns current record number (MFN).  Returns current record number (MFN).
244    
245   print $webpac->mfn;   print $isis->pos;
246    
247    First record in database has position 1.
248    
249  =cut  =cut
250    
251  sub mfn {  sub pos {
252          my $self = shift;          my $self = shift;
253          return $self->{'current_mfn'};          return $self->{'current_mfn'};
254  }  }
255    
256    
257    =head2 size
258    
259    Returns number of records in database
260    
261     print $isis->size;
262    
263    =cut
264    
265    sub size {
266            my $self = shift;
267            return $self->{'max_mfn'};
268    }
269    
270    =head2 seek
271    
272    Seek to specified MFN in file.
273    
274     $isis->seek(42);
275    
276    First record in database has position 1.
277    
278    =cut
279    
280    sub seek {
281            my $self = shift;
282            my $pos = shift || return;
283    
284            my $log = $self->_get_logger();
285    
286            if ($pos < 1) {
287                    $log->warn("seek before first record");
288                    $pos = 1;
289            } elsif ($pos > $self->{'max_mfn'}) {
290                    $log->warn("seek beyond last record");
291                    $pos = $self->{'max_mfn'};
292            }
293    
294            return $self->{'current_mfn'} = (($pos - 1) || -1);
295    }
296    
297  =head1 AUTHOR  =head1 AUTHOR
298    
299  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>

Legend:
Removed from v.6  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26