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

Inherits:
Object
  • Object
show all
Extended by:
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

as_source_class, is_destination?, special_options

Methods included from Registry::Fileable

#default_args, #default_file_options, #labeled_options, #options_key, #path_key, #requires_path?

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



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

def initialize(filename:, allow_oversized: nil)
  @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
20
21
# File 'lib/kiba/extend/destinations/marc.rb', line 19

def as_source_class
  Kiba::Extend::Sources::Marc
end

.default_file_optionsObject

Since:

  • 4.0.0



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

def default_file_options
  nil
end

.options_keyObject

Since:

  • 4.0.0



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

def options_key
  nil
end

.path_keyObject

Since:

  • 4.0.0



31
32
33
# File 'lib/kiba/extend/destinations/marc.rb', line 31

def path_key
  :filename
end

.requires_path?Boolean

Returns:

  • (Boolean)

Since:

  • 4.0.0



35
36
37
# File 'lib/kiba/extend/destinations/marc.rb', line 35

def requires_path?
  true
end

.special_optionsObject

Since:

  • 4.0.0



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

def special_options
  [:allow_oversized]
end

Instance Method Details

#closeObject

Since:

  • 4.0.0



59
60
61
# File 'lib/kiba/extend/destinations/marc.rb', line 59

def close
  writer.close
end

#write(record) ⇒ Object

Parameters:

  • record (MARC::Record)

Since:

  • 4.0.0



54
55
56
# File 'lib/kiba/extend/destinations/marc.rb', line 54

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