Class: Kiba::Extend::Transforms::Marc::ExtractIds

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/extend/transforms/marc/extract_ids.rb

Overview

Extract :marcid values from all records in file based on config settings defined in Marc

Examples:

rec = get_marc_record(index: 0)
xform = Marc::ExtractIds.new
result = xform.process(rec)
expected = "008000103-3"
expect(result[Kiba::Extend::Marc.id_target_field]).to eq(expected)

Since:

  • 3.3.0

Instance Method Summary collapse

Constructor Details

#initialize(id_target: Kiba::Extend::Marc.id_target_field) ⇒ ExtractIds

Returns a new instance of ExtractIds.

Parameters:

  • id_target (Symbol) (defaults to: Kiba::Extend::Marc.id_target_field)

    row field into which id value will be written

Since:

  • 3.3.0



21
22
23
24
# File 'lib/kiba/extend/transforms/marc/extract_ids.rb', line 21

def initialize(id_target: Kiba::Extend::Marc.id_target_field)
  @id_target = id_target
  @idextractor = Kiba::Extend::Utils::MarcIdExtractor.new
end

Instance Method Details

#process(record) ⇒ Hash{ Symbol => String, nil }

Parameters:

  • record (MARC::Record)

Returns:

  • (Hash{ Symbol => String, nil })

Since:

  • 3.3.0



28
29
30
# File 'lib/kiba/extend/transforms/marc/extract_ids.rb', line 28

def process(record)
  {id_target => idextractor.call(record)}
end