Class: Cocina::Models::Mapping::Normalizers::Mods::TitleNormalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/models/mapping/normalizers/mods/title_normalizer.rb

Overview

Normalizes a Fedora MODS document for title elements.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mods_ng_xml:, label:) ⇒ TitleNormalizer

Returns a new instance of TitleNormalizer.



21
22
23
24
25
# File 'lib/cocina/models/mapping/normalizers/mods/title_normalizer.rb', line 21

def initialize(mods_ng_xml:, label:)
  @ng_xml = mods_ng_xml.dup
  @ng_xml.encoding = 'UTF-8'
  @label = label
end

Class Method Details

.normalize(mods_ng_xml:, label:) ⇒ Nokogiri::Document

Returns normalized MODS.

Parameters:

  • mods_ng_xml (Nokogiri::Document)

    MODS to be normalized

  • label (String)

Returns:

  • (Nokogiri::Document)

    normalized MODS



13
14
15
# File 'lib/cocina/models/mapping/normalizers/mods/title_normalizer.rb', line 13

def self.normalize(mods_ng_xml:, label:)
  new(mods_ng_xml: mods_ng_xml, label: label).normalize
end

.normalize_missing_title(mods_ng_xml:, label:) ⇒ Object



17
18
19
# File 'lib/cocina/models/mapping/normalizers/mods/title_normalizer.rb', line 17

def self.normalize_missing_title(mods_ng_xml:, label:)
  new(mods_ng_xml: mods_ng_xml, label: label).normalize_missing_title
end

Instance Method Details

#normalizeObject



27
28
29
30
31
32
33
34
# File 'lib/cocina/models/mapping/normalizers/mods/title_normalizer.rb', line 27

def normalize
  normalize_hydrus_title
  clean_empty_titles
  normalize_title_type
  normalize_title_trailing
  normalize_title_as_label
  ng_xml
end

#normalize_missing_titleObject



36
37
38
39
# File 'lib/cocina/models/mapping/normalizers/mods/title_normalizer.rb', line 36

def normalize_missing_title
  normalize_title_as_label
  ng_xml
end