Class MARC::Reader
In: lib/marc/reader.rb
Parent: Object

Methods

decode   each   new  

Included Modules

Enumerable

Public Class methods

A static method for turning raw MARC data in transission format into a MARC::Record object.

The constructor which you may pass either a path

  reader = MARC::Reader.new('marc.dat')

or, if it‘s more convenient a File object:

  fh = File.new('marc.dat')
  reader = MARC::Reader.new(fh)

or really any object that responds to read(n)

  # marc is a string with a bunch of records in it
  reader = MARC::Reader.new(StringIO.new(reader))

If your data have non-standard control fields in them (e.g., Aleph‘s ‘FMT’) you need to add them specifically to the MARC::ControlField.control_tags Set object

  MARC::ControlField.control_tags << 'FMT'

Public Instance methods

to support iteration:

  for record in reader
    print record
  end

and even searching:

  record.find { |f| f['245'] =~ /Huckleberry/ }

[Validate]