Class: CocinaDisplay::Events::Location
- Inherits:
-
Object
- Object
- CocinaDisplay::Events::Location
- Defined in:
- lib/cocina_display/events/location.rb
Overview
A single location represented in a Cocina event, like a publication place.
Constant Summary collapse
- MARC_COUNTRIES_FILE_PATH =
File.join(__dir__, "..", "..", "..", "config", "marc_countries.yml").freeze
Instance Attribute Summary collapse
-
#cocina ⇒ Object
readonly
Returns the value of attribute cocina.
Class Method Summary collapse
-
.marc_countries ⇒ Hash{String => String}
A hash mapping MARC country codes to their names.
Instance Method Summary collapse
-
#initialize(cocina) ⇒ Location
constructor
Initialize a Location object with Cocina structured data.
-
#to_s ⇒ String?
The name of the location.
-
#unencoded_value? ⇒ Boolean
Is there an unencoded value (name) for this location?.
Constructor Details
#initialize(cocina) ⇒ Location
Initialize a Location object with Cocina structured data.
17 18 19 |
# File 'lib/cocina_display/events/location.rb', line 17 def initialize(cocina) @cocina = cocina end |
Instance Attribute Details
#cocina ⇒ Object (readonly)
Returns the value of attribute cocina.
7 8 9 |
# File 'lib/cocina_display/events/location.rb', line 7 def cocina @cocina end |
Class Method Details
.marc_countries ⇒ Hash{String => String}
A hash mapping MARC country codes to their names.
11 12 13 |
# File 'lib/cocina_display/events/location.rb', line 11 def self.marc_countries @marc_countries ||= YAML.safe_load_file(MARC_COUNTRIES_FILE_PATH) end |
Instance Method Details
#to_s ⇒ String?
The name of the location. Decodes a MARC country code if present and no value was present.
24 25 26 |
# File 'lib/cocina_display/events/location.rb', line 24 def to_s cocina["value"] || decoded_country end |
#unencoded_value? ⇒ Boolean
Is there an unencoded value (name) for this location?
30 31 32 |
# File 'lib/cocina_display/events/location.rb', line 30 def unencoded_value? cocina["value"].present? end |