NAME

MARC::Moose::Record - MARC::Moose bibliographic record

VERSION

version 1.0.49

DESCRIPTION

MARC::Moose::Record is an object, Moose based object, representing a MARC::Moose bibliographic record. It can be a MARC21, UNIMARC, or whatever biblio record.

ATTRIBUTES

lint

A MARC::Moose::Lint::Checker object which allow to check record based on a set of validation rules. Generally, the 'lint' attribute of record is inherited from the reader used to get the record.

leader

Read-only string. The leader is fixed by set_leader_length method.

fields

ArrayRef on MARC::Moose::Field objects: MARC::Moose:Fields::Control and MARC::Moose::Field::Std.

METHODS

clone()

Clone the record. Create a new record containing exactly the same data.

set_leader_length( length, offset )

This method is called to reset leader length of record and offset of data section. This means something only for ISO2709 formated records. So this method is exlusively called by any formater which has to build a valid ISO2709 data stream. It also forces leader position 10 and 20-23 since this variable values aren't variable at all for any ordinary MARC record.

Called by MARC::Moose::Formater::Iso2709.

$record->set_leader_length( $length, $offset );

append( field )

Append a MARC::Moose::Field in the record. The record is appended at the end of numerical section, ie if you append for example a 710 field, it will be placed at the end of the 7xx fields section, just before 8xx section or at the end of fields list.

$record->append(
  MARC::Moose::Field::Std->new(
   tag  => '100',
   subf => [ [ a => 'Poe, Edgar Allan' ],
             [ u => 'Translation' ] ]
) );

You can also append an array of MARC::Moose::Field. In this case, the array will be appended as for a unique field at the position of the first field of the array.

field( tag )

Returns a list of tags that match the field specifier, or an empty list if nothing matched. In scalar context, returns the first matching tag, or undef if nothing matched.

The field specifier can be a simple number (i.e. "245"), or use the "." notation of wildcarding (i.e. subject tags are "6.."). All fields are returned if "..." is specified.

delete(spec1, spec2, ...)

Delete all fields with tags matching the given specification. For example:

$record->delete('11.', '\d\d9');

will delete all fields with tag begining by '11' and ending with '9'.

as( format )

Returns a formated version of the record as defined by format. Format are standard formater provided by the MARC::Moose::Record package: Iso2709, Text, Marcxml, Json, Yaml, Legacy.

SYNOPSYS

use MARC::Moose::Record;
use MARC::Moose::Field::Control;
use MARC::Moose::Field::Std;
use MARC::Moose::Formater::Text;

my $record = MARC::Moose::Record->new(
    fields => [
        MARC::Moose::Field::Control->new(
            tag => '001',
            value => '1234' ),
        MARC::Moose::Field::Std->new(
            tag => '245',
            subf => [ [ a => 'MARC is dying for ever:' ], [ b => 'will it ever happen?' ] ] ),
        MARC::Moose::Field::Std->new(
            tag => '260',
            subf => [
                [ a => 'Paris:' ],
                [ b => 'Usefull Press,' ],
                [ c => '2010.' ],
            ] ),
        MARC::Moose::Field::Std->new(
            tag => '600',
            subf => [ [ a => 'Library' ], [ b => 'Standards' ] ] ),
        MARC::Moose::Field::Std->new(
            tag => '900',
            subf => [ [ a => 'My local field 1' ] ] ),
        MARC::Moose::Field::Std->new(
            tag => '901',
            subf => [ [ a => 'My local field 1' ] ] ),
    ]
);
  
my $formater = MARC::Moose::Formater::Text->new();
print $formater->format( $record );
# Shortcut:
print $record->as('Text');

$record->fields( [ grep { $_->tag < 900 } @{$record->fields} ] );
print "After local fields removing:\n", $formater->format($record);

SEE ALSO

AUTHOR

Frédéric Demians <f.demians@tamil.fr>

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by Frédéric Demians.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.