Class: Kiba::Extend::Destinations::Marc

Inherits:
Object
  • Object
show all
Includes:
Destinationable
Defined in:
lib/kiba/extend/destinations/marc.rb

Overview

Writes MARC records to a file

This is a wrapper around ruby-marc’s MARC::Writer, so see relevant documentation in: https://github.com/ruby-marc/ruby-marc/blob/main/lib/marc/writer.rb

Since:

  • 4.0.0

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Destinationable

#ensure_dir, included, is_destination?

Constructor Details

#initialize(filename:, allow_oversized: nil) ⇒ Marc

Returns a new instance of Marc.

Parameters:

  • filename (String)

    path for writing MARC file

  • allow_oversized (Boolean, nil) (defaults to: nil)

    If given, will set MARC::Writer’s allow_oversized attribute. Set in registry entry’s dest_special_opts

Since:

  • 4.0.0



36
37
38
39
40
41
# File 'lib/kiba/extend/destinations/marc.rb', line 36

def initialize(filename:, allow_oversized: nil)
  @filename = filename
  ensure_dir
  @writer = MARC::Writer.new(filename)
  writer.allow_oversized = allow_oversized if allow_oversized
end

Class Method Details

.as_source_classObject

Since:

  • 4.0.0



19
# File 'lib/kiba/extend/destinations/marc.rb', line 19

def as_source_class = Kiba::Extend::Sources::Marc

.default_file_optionsObject

Since:

  • 4.0.0



21
# File 'lib/kiba/extend/destinations/marc.rb', line 21

def default_file_options = nil

.options_keyObject

Since:

  • 4.0.0



23
# File 'lib/kiba/extend/destinations/marc.rb', line 23

def options_key = nil

.path_keyObject

Since:

  • 4.0.0



25
# File 'lib/kiba/extend/destinations/marc.rb', line 25

def path_key = :filename

.requires_path?Boolean

Returns:

  • (Boolean)

Since:

  • 4.0.0



27
# File 'lib/kiba/extend/destinations/marc.rb', line 27

def requires_path? = true

.special_optionsObject

Since:

  • 4.0.0



29
# File 'lib/kiba/extend/destinations/marc.rb', line 29

def special_options = [:allow_oversized]

Instance Method Details

#closeObject

Since:

  • 4.0.0



49
50
51
# File 'lib/kiba/extend/destinations/marc.rb', line 49

def close
  writer.close
end

#write(record) ⇒ Object

Parameters:

  • record (MARC::Record)

Since:

  • 4.0.0



44
45
46
# File 'lib/kiba/extend/destinations/marc.rb', line 44

def write(record)
  writer.write(record)
end