Class: Cocina::Models::Mapping::ToMods::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/models/mapping/to_mods/event.rb

Overview

Maps events from cocina to MODS XML

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml:, events:, id_generator:) ⇒ Event

Returns a new instance of Event.



16
17
18
19
20
# File 'lib/cocina/models/mapping/to_mods/event.rb', line 16

def initialize(xml:, events:, id_generator:)
  @xml = xml
  @events = events
  @id_generator = id_generator
end

Class Method Details

.write(xml:, events:, id_generator:) ⇒ Object



12
13
14
# File 'lib/cocina/models/mapping/to_mods/event.rb', line 12

def self.write(xml:, events:, id_generator:)
  new(xml: xml, events: events, id_generator: id_generator).write
end

Instance Method Details

#writeObject



22
23
24
25
26
27
28
29
30
# File 'lib/cocina/models/mapping/to_mods/event.rb', line 22

def write
  Array(events).each do |event|
    if event.parallelEvent.present?
      write_parallel(event, id_generator.next_altrepgroup)
    else
      write_basic(event, event.type)
    end
  end
end