Class: Cocina::Models::Mapping::ToMods::RelatedResource
- Inherits:
-
Object
- Object
- Cocina::Models::Mapping::ToMods::RelatedResource
- Defined in:
- lib/cocina/models/mapping/to_mods/related_resource.rb
Overview
Maps relatedResource from cocina to MODS relatedItem
Constant Summary collapse
- TYPES =
{ 'has original version' => 'original', 'has other format' => 'otherFormat', 'has part' => 'constituent', 'has version' => 'otherVersion', 'in series' => 'series', 'part of' => 'host', 'preceded by' => 'preceding', 'related to' => nil, # 'related to' is a null type by design 'reviewed by' => 'reviewOf', 'referenced by' => 'isReferencedBy', 'references' => 'references', 'succeeded by' => 'succeeding' }.freeze
- DETAIL_TYPES =
{ 'location within source' => 'part', 'volume' => 'volume', 'issue' => 'issue', 'chapter' => 'chapter', 'section' => 'section', 'paragraph' => 'paragraph', 'track' => 'track', 'marker' => 'marker' }.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(xml:, related_resources:, druid:, id_generator:) ⇒ RelatedResource
constructor
A new instance of RelatedResource.
- #write ⇒ Object
Constructor Details
#initialize(xml:, related_resources:, druid:, id_generator:) ⇒ RelatedResource
Returns a new instance of RelatedResource.
44 45 46 47 48 49 |
# File 'lib/cocina/models/mapping/to_mods/related_resource.rb', line 44 def initialize(xml:, related_resources:, druid:, id_generator:) @xml = xml @related_resources = Array() @druid = druid @id_generator = id_generator end |
Class Method Details
.write(xml:, related_resources:, druid:, id_generator:) ⇒ Object
40 41 42 |
# File 'lib/cocina/models/mapping/to_mods/related_resource.rb', line 40 def self.write(xml:, related_resources:, druid:, id_generator:) new(xml: xml, related_resources: , druid: druid, id_generator: id_generator).write end |
Instance Method Details
#write ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cocina/models/mapping/to_mods/related_resource.rb', line 51 def write .each do |(attributes, , )| xml. attributes do ModsWriter.write(xml: xml, description: , druid: druid, id_generator: id_generator) end end .filter(&:valueAt).each do || xml. nil, { 'xlink:href' => .valueAt } end end |