Class: Cocina::Models::Mapping::FromMods::Form

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

Overview

Maps relevant MODS physicalDescription, typeOfResource and genre from descMetadata to cocina form rubocop:disable Metrics/ClassLength

Constant Summary collapse

H2_GENRE_TYPE_PREFIX =

NOTE: H2 is the first case of structured form (genre/typeOfResource) values we’re implementing

'H2 '

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_element:, description_builder:) ⇒ Form

Returns a new instance of Form.



21
22
23
24
# File 'lib/cocina/models/mapping/from_mods/form.rb', line 21

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



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

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

Instance Method Details

#buildObject



26
27
28
29
30
31
32
33
34
# File 'lib/cocina/models/mapping/from_mods/form.rb', line 26

def build
  forms = []
  add_genre(forms)
  add_types(forms)
  add_physical_descriptions(forms)
  add_subject_cartographics(forms)
  Primary.adjust(forms, 'genre', notifier, match_type: true)
  Primary.adjust(forms, 'resource type', notifier, match_type: true)
end