Class: Cocina::Models::Mapping::FromMods::Language

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

Overview

Maps languages

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_element:, description_builder:) ⇒ Language

Returns a new instance of Language.



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

def initialize(resource_element:, description_builder:)
  @resource_element = resource_element
  @notifier = description_builder.notifier
end

Class Method Details

.build(resource_element:, description_builder:, 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/language.rb', line 13

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

Instance Method Details

#buildObject



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

def build
  languages = resource_element.xpath('mods:language', mods: Description::DESC_METADATA_NS).map do |lang_node|
    Cocina::Models::Mapping::FromMods::LanguageTerm.build(language_element: lang_node, notifier: notifier)
  end
  Primary.adjust(languages, 'language', notifier)
end