Class: Cocina::Models::Mapping::FromMods::Identifier

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/models/mapping/from_mods/identifier.rb

Overview

Maps MODS identifer to cocina identifier

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_element:) ⇒ Identifier

Returns a new instance of Identifier.



17
18
19
# File 'lib/cocina/models/mapping/from_mods/identifier.rb', line 17

def initialize(resource_element:)
  @resource_element = resource_element
end

Class Method Details

.build(resource_element:, description_builder: nil, purl: nil) ⇒ Hash

Returns a hash that can be mapped to a cocina model.

Parameters:

Returns:

  • (Hash)

    a hash that can be mapped to a cocina model



13
14
15
# File 'lib/cocina/models/mapping/from_mods/identifier.rb', line 13

def self.build(resource_element:, description_builder: nil, purl: nil)
  new(resource_element: resource_element).build
end

Instance Method Details

#buildObject



21
22
23
24
25
26
27
28
# File 'lib/cocina/models/mapping/from_mods/identifier.rb', line 21

def build
  altrepgroup_identifier_nodes, other_identifier_nodes = AltRepGroup.split(nodes: identifiers)

  altrepgroup_identifier_nodes.map { |id_nodes| build_parallel(id_nodes) } +
    other_identifier_nodes.map do |id_node|
      IdentifierBuilder.build_from_identifier(identifier_element: id_node)
    end
end