Class: CocinaDisplay::Events::Note

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(cocina) ⇒ Note

Initialize a Note object with Cocina structured data.

Parameters:

  • cocina (Hash)

    The Cocina structured data for the note.



9
10
11
# File 'lib/cocina_display/events/note.rb', line 9

def initialize(cocina)
  @cocina = cocina
end

Instance Attribute Details

#cocinaObject (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

#labelString

The display label for the note.

Returns:

  • (String)


27
28
29
30
# File 'lib/cocina_display/events/note.rb', line 27

def label
  cocina["displayLabel"].presence ||
    I18n.t(type&.parameterize&.underscore, default: :default, scope: "cocina_display.field_label.event.note")
end

#to_sString?

The value of the note.

Returns:

  • (String, nil)


15
16
17
# File 'lib/cocina_display/events/note.rb', line 15

def to_s
  cocina["value"].presence
end

#typeString?

The type of the note, like “issuance” or “edition”.

Returns:

  • (String, nil)


21
22
23
# File 'lib/cocina_display/events/note.rb', line 21

def type
  cocina["type"].presence
end