Class: CocinaDisplay::Events::Note
- Inherits:
-
Object
- Object
- CocinaDisplay::Events::Note
- Defined in:
- lib/cocina_display/events/note.rb
Overview
A single note represented in a Cocina event, like an issuance or edition note.
Instance Attribute Summary collapse
-
#cocina ⇒ Object
readonly
Returns the value of attribute cocina.
Instance Method Summary collapse
-
#initialize(cocina) ⇒ Note
constructor
Initialize a Note object with Cocina structured data.
-
#label ⇒ String
The display label for the note.
-
#to_s ⇒ String?
Contents of the note.
-
#type ⇒ String?
The type of the note, like “issuance” or “edition”.
-
#value ⇒ String?
The contents of the note.
Constructor Details
#initialize(cocina) ⇒ Note
Initialize a Note object with Cocina structured data.
9 10 11 |
# File 'lib/cocina_display/events/note.rb', line 9 def initialize(cocina) @cocina = cocina end |
Instance Attribute Details
#cocina ⇒ Object (readonly)
Returns the value of attribute cocina.
5 6 7 |
# File 'lib/cocina_display/events/note.rb', line 5 def cocina @cocina end |
Instance Method Details
#label ⇒ String
The display label for the note.
39 40 41 42 |
# File 'lib/cocina_display/events/note.rb', line 39 def label cocina["displayLabel"].presence || I18n.t(type&.parameterize&.underscore, default: :default, scope: "cocina_display.field_label.event.note") end |
#to_s ⇒ String?
Note:
Issuance and frequency notes are lowercased for consistency.
Contents of the note.
16 17 18 19 20 21 22 23 |
# File 'lib/cocina_display/events/note.rb', line 16 def to_s case type when "issuance", "frequency" value&.downcase else value end end |
#type ⇒ String?
The type of the note, like “issuance” or “edition”.
33 34 35 |
# File 'lib/cocina_display/events/note.rb', line 33 def type cocina["type"].presence end |
#value ⇒ String?
The contents of the note.
27 28 29 |
# File 'lib/cocina_display/events/note.rb', line 27 def value cocina["value"].presence end |