--- trunk/lib/WebPAC/Input/ISIS.pm 2006/09/07 15:01:45 652 +++ trunk/lib/WebPAC/Input/ISIS.pm 2006/09/29 19:52:17 726 @@ -5,6 +5,7 @@ use WebPAC::Input; use Biblio::Isis 0.23; +use base qw/WebPAC::Common/; =head1 NAME @@ -12,11 +13,11 @@ =head1 VERSION -Version 0.07 +Version 0.08 =cut -our $VERSION = '0.07'; +our $VERSION = '0.08'; =head1 SYNOPSIS @@ -24,16 +25,17 @@ Open CDS/ISIS, WinISIS or IsisMarc database using C and read all records to memory. - my $isis = new WebPAC::Input::ISIS(); - $isis->open( path => '/path/to/ISIS/ISIS' ); + my $isis = new WebPAC::Input::ISIS( + path => '/path/to/ISIS/ISIS', + ); =head1 FUNCTIONS -=head2 open_db +=head2 new -Returns handle to database and size in records +Returns new low-level input API object - my ($db,$size) = $isis->open_db( + my $isis = new WebPAC::Input::ISIS( path => '/path/to/LIBRI' filter => sub { my ($l,$field_nr) = @_; @@ -54,8 +56,10 @@ =cut -sub open_db { - my $self = shift; +sub new { + my $class = shift; + my $self = {@_}; + bless($self, $class); my $arg = {@_}; @@ -70,18 +74,16 @@ hash_filter => $arg->{filter} ? sub { return $arg->{filter}->(@_); } : undef, ) or $log->logdie("can't find database $arg->{path}"); - my $size = $isis_db->count; - $self->{_isis_db} = $isis_db; - return ($isis_db, $size); + $self ? return $self : return undef; } =head2 fetch_rec Return record with ID C<$mfn> from database - my $rec = $self->fetch_rec( $mfn, $filter_coderef); + my $rec = $isis->fetch_rec( $mfn, $filter_coderef); =cut @@ -110,7 +112,7 @@ Return dump of record ID C<$mfn> from database - my $rec = $self->dump_rec( $db, $mfn ); + my $rec = $isis->dump_rec( $db, $mfn ); =cut @@ -122,6 +124,19 @@ return $self->{_isis_db}->to_ascii( $mfn ); } +=head2 size + +Return number of records in database + + my $size = $isis->size; + +=cut + +sub size { + my $self = shift; + return $self->{_isis_db}->count; +} + =head1 AUTHOR Dobrica Pavlinusic, C<< >>