Class: Cocina::Models::Mapping::FromMods::Geographic

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

Overview

Maps MODS extension displayLabel geo to cocina descriptive extension rubocop:disable Metrics/ClassLength

Constant Summary collapse

DUBLIN_CORE_NS =
'http://purl.org/dc/elements/1.1/'
RDF_NS =
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
GMD_NS =
'http://www.isotc211.org/2005/gmd'
GML_NS =
'http://www.opengis.net/gml/3.2/'
NAMESPACE =
{
  'mods' => Description::DESC_METADATA_NS,
  'dc' => DUBLIN_CORE_NS,
  'rdf' => RDF_NS,
  'gmd' => GMD_NS,
  'gml' => GML_NS
}.freeze
SOUTH =

Directional Constants for GEO

'south'
WEST =
'west'
NORTH =
'north'
EAST =
'east'
BOUNDING_BOX_COORDS =

Geo Extention Constants

'bounding box coordinates'
COVERAGE =
'coverage'
DATA_FORMAT =
'data format'
DCMI_VOCAB =
{ value: 'DCMI Type Vocabulary' }.freeze
DECIMAL_ENCODING =
{ value: 'decimal' }.freeze
FORMAT_DELIM =
'; format='
IANA_TERMS =
{ value: 'IANA media type terms' }.freeze
LANGUAGE =
{ code: 'eng' }.freeze
MEDIA_TYPE =
'media type'
POINT_COORDS =
'point coordinates'
TYPE =
'type'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_element:, description_builder:) ⇒ Geographic

Returns a new instance of Geographic.



50
51
52
53
# File 'lib/cocina/models/mapping/from_mods/geographic.rb', line 50

def initialize(resource_element:, description_builder:)
  @resource_element = resource_element
  @notifier = description_builder.notifier
end

Class Method Details

.build(resource_element:, description_builder:, purl: nil) ⇒ Hash

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

Parameters:

Returns:

  • (Hash)

    a hash that can be mapped to a cocina model



46
47
48
# File 'lib/cocina/models/mapping/from_mods/geographic.rb', line 46

def self.build(resource_element:, description_builder:, purl: nil)
  new(resource_element: resource_element, description_builder: description_builder).build
end

Instance Method Details

#buildObject



55
56
57
58
59
60
61
62
63
64
# File 'lib/cocina/models/mapping/from_mods/geographic.rb', line 55

def build
  return unless description

  check_purl

  [{}.tap do |extension|
    extension[:form] = build_form.flatten if build_form
    extension[:subject] = build_subject
  end.compact]
end