Class: Kiba::Extend::Transforms::Marc::ExtractBaseNameData Abstract

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

Overview

This class is abstract.

Base class with shared name extraction behaviors

Since:

  • 3.3.0

Instance Method Summary collapse

Methods included from FieldLinkable

#select_fields

Constructor Details

#initialize(name_type:, name_fields:, name_subfields:, role_code_subfields:, role_term_subfields:, id_target: Kiba::Extend::Marc.id_target_field, name_target: Kiba::Extend::Marc.name_target, role_term_target: Kiba::Extend::Marc.role_term_target, role_code_target: Kiba::Extend::Marc.role_code_target, field_tag_target: Kiba::Extend::Marc.field_tag_target, name_type_target: Kiba::Extend::Marc.name_type_target, delim: Kiba::Extend.delim) ⇒ ExtractBaseNameData

Returns a new instance of ExtractBaseNameData.

Parameters:

  • name_type (String)

    to insert into name_type_target field

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

    row field into which id value will be written

  • name_target (Symbol) (defaults to: Kiba::Extend::Marc.name_target)

    row field into which name value will be written

  • role_term_target (Symbol) (defaults to: Kiba::Extend::Marc.role_term_target)

    row field into which role term value will be written

  • role_code_target (Symbol) (defaults to: Kiba::Extend::Marc.role_code_target)

    row field into which role code value will be written

  • field_tag_target (Symbol) (defaults to: Kiba::Extend::Marc.field_tag_target)

    row field into which field tag value will be written

  • name_type_target (Symbol) (defaults to: Kiba::Extend::Marc.name_type_target)

    row field into which name type value will be written

  • name_fields (Array<String>)

    MARC fields from which name data will be extracted

  • name_subfields (Array<String>)

    subfields to extract as part of name value.

  • role_code_subfields (Array<String>)

    subfields to extract as role code value

  • role_term_subfields (Array<String>)

    subfields to extract as role term value

  • delim (String) (defaults to: Kiba::Extend.delim)

    used when joining multiple values in a field

Since:

  • 3.3.0



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/kiba/extend/transforms/marc/extract_base_name_data.rb', line 35

def initialize(name_type:, name_fields:, name_subfields:,
  role_code_subfields:, role_term_subfields:,
  id_target: Kiba::Extend::Marc.id_target_field,
  name_target: Kiba::Extend::Marc.name_target,
  role_term_target: Kiba::Extend::Marc.role_term_target,
  role_code_target: Kiba::Extend::Marc.role_code_target,
  field_tag_target: Kiba::Extend::Marc.field_tag_target,
  name_type_target: Kiba::Extend::Marc.name_type_target,
  delim: Kiba::Extend.delim)
  @name_type = name_type
  @id_target = id_target
  @name_target = name_target
  @role_term_target = role_term_target
  @role_code_target = role_code_target
  @field_tag_target = field_tag_target
  @name_type_target = name_type_target
  @name_fields = name_fields
  @name_subfields = name_subfields
  @role_term_subfields = role_term_subfields
  @role_code_subfields = role_code_subfields
  @delim = delim
  @idextractor = Kiba::Extend::Utils::MarcIdExtractor.new
  @namecleaner = Kiba::Extend::Utils::MarcNameCleaner.new
  @roletermcleaner = Kiba::Extend::Utils::MarcRoleTermCleaner.new
end

Instance Method Details

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

Parameters:

  • record (MARC::Record)

Returns:

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

Since:

  • 3.3.0



63
64
65
66
67
68
69
# File 'lib/kiba/extend/transforms/marc/extract_base_name_data.rb', line 63

def process(record)
  prepare_rows(record).each do |row|
    yield row
  end

  nil
end