Class: CocinaDisplay::Subjects::SubjectValue
- Inherits:
-
Object
- Object
- CocinaDisplay::Subjects::SubjectValue
- Defined in:
- lib/cocina_display/subjects/subject_value.rb
Overview
A descriptive value that can be part of a Subject.
Direct Known Subclasses
CoordinatesSubjectValue, NameSubjectValue, PlaceSubjectValue, TemporalSubjectValue, TitleSubjectValue
Instance Attribute Summary collapse
-
#cocina ⇒ Object
readonly
Returns the value of attribute cocina.
-
#type ⇒ Object
The type of the subject value, like “person”, “title”, or “time”.
Class Method Summary collapse
-
.atomic_types ⇒ Array<String>
All subject value types that should not be further destructured.
-
.from_cocina(cocina) ⇒ SubjectValue
Create a SubjectValue from Cocina structured data.
Instance Method Summary collapse
-
#display_str ⇒ String
The display string for the subject value.
-
#initialize(cocina) ⇒ SubjectValue
constructor
Initialize a SubjectValue object with Cocina structured data.
Constructor Details
#initialize(cocina) ⇒ SubjectValue
Initialize a SubjectValue object with Cocina structured data.
34 35 36 37 |
# File 'lib/cocina_display/subjects/subject_value.rb', line 34 def initialize(cocina) @cocina = cocina @type = cocina["type"] end |
Instance Attribute Details
#cocina ⇒ Object (readonly)
Returns the value of attribute cocina.
13 14 15 |
# File 'lib/cocina_display/subjects/subject_value.rb', line 13 def cocina @cocina end |
#type ⇒ Object
The type of the subject value, like “person”, “title”, or “time”.
17 18 19 |
# File 'lib/cocina_display/subjects/subject_value.rb', line 17 def type @type end |
Class Method Details
.atomic_types ⇒ Array<String>
All subject value types that should not be further destructured.
28 29 30 |
# File 'lib/cocina_display/subjects/subject_value.rb', line 28 def self.atomic_types SUBJECT_VALUE_TYPES.keys - ["place"] end |
.from_cocina(cocina) ⇒ SubjectValue
Create a SubjectValue from Cocina structured data.
22 23 24 |
# File 'lib/cocina_display/subjects/subject_value.rb', line 22 def self.from_cocina(cocina) SUBJECT_VALUE_TYPES.fetch(cocina["type"], SubjectValue).new(cocina) end |
Instance Method Details
#display_str ⇒ String
The display string for the subject value. Subclasses should override this method to provide specific formatting.
42 43 44 |
# File 'lib/cocina_display/subjects/subject_value.rb', line 42 def display_str cocina["value"] end |