Class: CocinaDisplay::Contributors::Name
- Inherits:
-
Object
- Object
- CocinaDisplay::Contributors::Name
- Defined in:
- lib/cocina_display/contributors/name.rb
Overview
A name associated with a contributor.
Instance Attribute Summary collapse
-
#cocina ⇒ Object
readonly
Returns the value of attribute cocina.
Instance Method Summary collapse
-
#display_str(with_date: false) ⇒ String
The display string for the name, optionally including life dates.
-
#initialize(cocina) ⇒ Name
constructor
Initialize a Name object with Cocina structured data.
Constructor Details
#initialize(cocina) ⇒ Name
Initialize a Name object with Cocina structured data.
13 14 15 |
# File 'lib/cocina_display/contributors/name.rb', line 13 def initialize(cocina) @cocina = cocina end |
Instance Attribute Details
#cocina ⇒ Object (readonly)
Returns the value of attribute cocina.
9 10 11 |
# File 'lib/cocina_display/contributors/name.rb', line 9 def cocina @cocina end |
Instance Method Details
#display_str(with_date: false) ⇒ String
The display string for the name, optionally including life dates. Uses these values in order, if present:
-
Unstructured value
-
Any structured/parallel values marked as “display”
-
Joined structured values, optionally with life dates
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cocina_display/contributors/name.rb', line 28 def display_str(with_date: false) if cocina["value"].present? cocina["value"] elsif display_name_str.present? display_name_str elsif dates_str.present? && with_date Utils.compact_and_join([full_name_str, dates_str], delimiter: ", ") else full_name_str end end |