Class: CocinaDisplay::Events::LocationValue

Inherits:
Parallel::ParallelValue show all
Defined in:
lib/cocina_display/events/location_value.rb

Overview

A location in a Cocina event in a single language/script.

Constant Summary

Constants inherited from Parallel::ParallelValue

Parallel::ParallelValue::PARALLEL_TYPES

Instance Attribute Summary

Attributes inherited from Parallel::ParallelValue

#cocina, #parent, #role

Instance Method Summary collapse

Methods inherited from Parallel::ParallelValue

#display?, #initialize, #language, #main_value, #own_type, #own_typed?, #primary?, #siblings, #status, #translated?, #transliterated?, #type, #typed?, #vernacular?

Constructor Details

This class inherits a constructor from CocinaDisplay::Parallel::ParallelValue

Instance Method Details

#country_name ⇒ String?

Decoded country name if the location is encoded with a MARC country code.

Returns:

  • (String, nil)


20
21
22
# File 'lib/cocina_display/events/location_value.rb', line 20

def country_name
  Location.marc_countries[code] if marc_country? && valid_country_code?
end

#to_s ⇒ String?

The name of the location. Decodes a MARC country code if present and no value was present.

Returns:

  • (String, nil)


8
9
10
# File 'lib/cocina_display/events/location_value.rb', line 8

def to_s
  cocina["value"] || country_name
end

#unencoded_value? ⇒ Boolean

Is there an unencoded value (name) for this location?

Returns:

  • (Boolean)


14
15
16
# File 'lib/cocina_display/events/location_value.rb', line 14

def unencoded_value?
  cocina["value"].present?
end