Class: Cocina::Models::Mapping::FromMods::Description

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

Overview

Creates Cocina Description objects from MODS xml

Constant Summary collapse

DESC_METADATA_NS =
'http://www.loc.gov/mods/v3'
'http://www.w3.org/1999/xlink'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title_builder:, mods:, label:, druid:, notifier:) ⇒ Description

Returns a new instance of Description.



22
23
24
25
26
27
28
# File 'lib/cocina/models/mapping/from_mods/description.rb', line 22

def initialize(title_builder:, mods:, label:, druid:, notifier:)
  @title_builder = title_builder
  @ng_xml = mods
  @notifier = notifier || ErrorNotifier.new(druid: druid)
  @druid = druid
  @label = label
end

Class Method Details

.props(mods:, druid:, label:, title_builder: Title, notifier: nil) ⇒ Hash

Returns a hash that can be mapped to a cocina descriptive model.

Parameters:

Returns:

  • (Hash)

    a hash that can be mapped to a cocina descriptive model



18
19
20
# File 'lib/cocina/models/mapping/from_mods/description.rb', line 18

def self.props(mods:, druid:, label:, title_builder: Title, notifier: nil)
  new(title_builder: title_builder, mods: mods, druid: druid, label: label, notifier: notifier).props
end

Instance Method Details

#propsHash

Returns a hash that can be mapped to a cocina descriptive model.

Returns:

  • (Hash)

    a hash that can be mapped to a cocina descriptive model



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cocina/models/mapping/from_mods/description.rb', line 32

def props
  return nil if ng_xml.root.nil?

  check_altrepgroups
  check_version
  props = DescriptionBuilder.build(title_builder: title_builder,
                                   resource_element: ng_xml.root,
                                   notifier: notifier,
                                   purl: druid ? Cocina::Models::Mapping::Purl.for(druid: druid) : nil)
  props[:title] = [{ value: label }] unless props.key?(:title)
  props
end