Class: Cocina::Models::Mapping::ToMods::Access

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

Overview

Maps the Access subschema from cocina to MODS XML

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml:, access:, purl:) ⇒ Access

Returns a new instance of Access.



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

def initialize(xml:, access:, purl:)
  @xml = xml
  @access = access
  @purl = purl
end

Class Method Details

.write(xml:, access:, purl:) ⇒ Object



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

def self.write(xml:, access:, purl:)
  new(xml: xml, access: access, purl: purl).write
end

Instance Method Details

#writeObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cocina/models/mapping/to_mods/access.rb', line 22

def write
  write_purl unless purl.nil?
  return if access.nil?

  write_access_conditions if access

  Array(access.url).each do |url|
    xml.location do
      write_url(url)
    end
  end

  write_physical_locations
  write_digital_locations
  write_shelf_locators
  write_access_contact_locations
end