Class: Cocina::Models::Mapping::ToMods::Form
- Inherits:
-
Object
- Object
- Cocina::Models::Mapping::ToMods::Form
- Defined in:
- lib/cocina/models/mapping/to_mods/form.rb
Overview
Maps forms from cocina to MODS XML
Constant Summary collapse
- H2_SOURCE_LABEL =
NOTE: H2 is the first case of structured form values we’re implementing
'Stanford self-deposit resource types'
- PHYSICAL_DESCRIPTION_TAG =
{ 'carrier' => :form, 'digital origin' => :digitalOrigin, 'extent' => :extent, 'form' => :form, 'material' => :form, 'media' => :form, 'media type' => :internetMediaType, 'reformatting quality' => :reformattingQuality, 'technique' => :form }.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(xml:, forms:, id_generator:) ⇒ Form
constructor
A new instance of Form.
- #write ⇒ Object
Constructor Details
#initialize(xml:, forms:, id_generator:) ⇒ Form
Returns a new instance of Form.
30 31 32 33 34 |
# File 'lib/cocina/models/mapping/to_mods/form.rb', line 30 def initialize(xml:, forms:, id_generator:) @xml = xml @forms = forms @id_generator = id_generator end |
Class Method Details
.write(xml:, forms:, id_generator:) ⇒ Object
26 27 28 |
# File 'lib/cocina/models/mapping/to_mods/form.rb', line 26 def self.write(xml:, forms:, id_generator:) new(xml: xml, forms: forms, id_generator: id_generator).write end |
Instance Method Details
#write ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cocina/models/mapping/to_mods/form.rb', line 36 def write other_forms = Array(forms).reject do |form| physical_description?(form) || manuscript?(form) || collection?(form) end is_manuscript = Array(forms).any? { |form| manuscript?(form) } is_collection = Array(forms).any? { |form| collection?(form) } if other_forms.present? write_other_forms(other_forms, is_manuscript, is_collection) else write_attributes_only(is_manuscript, is_collection) end write_physical_descriptions end |