Class: CocinaDisplay::Contributors::Affiliation
- Inherits:
-
Object
- Object
- CocinaDisplay::Contributors::Affiliation
- Defined in:
- lib/cocina_display/contributors/affiliation.rb
Overview
An affiliation associated with a contributor.
Instance Attribute Summary collapse
-
#cocina ⇒ Object
readonly
Returns the value of attribute cocina.
Instance Method Summary collapse
-
#display_name ⇒ String?
The name of the institution or organization.
-
#identifiers ⇒ Array<CocinaDisplay::Identifier>
Identifiers associated with the Affiliation.
-
#initialize(cocina) ⇒ Affiliation
constructor
Initialize an Affiliation from Cocina structured data.
-
#name_components ⇒ Array<String>
All components of the Affiliation name as an array of strings.
-
#ror ⇒ String?
ROR URI for the Affiliation, if present.
-
#ror? ⇒ Boolean
Does this Affiliation have a ROR ID?.
-
#ror_id ⇒ String?
ROR ID for the Affiliation, if present.
-
#ror_identifier ⇒ CocinaDisplay::Identifier?
The first Identifier object that contains a ROR ID.
-
#to_s ⇒ String?
String representation of the affiliation, using display name.
Constructor Details
#initialize(cocina) ⇒ Affiliation
Initialize an Affiliation from Cocina structured data.
11 12 13 |
# File 'lib/cocina_display/contributors/affiliation.rb', line 11 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/contributors/affiliation.rb', line 7 def cocina @cocina end |
Instance Method Details
#display_name ⇒ String?
The name of the institution or organization.
24 25 26 |
# File 'lib/cocina_display/contributors/affiliation.rb', line 24 def display_name name_components.join(", ") if name_components.any? end |
#identifiers ⇒ Array<CocinaDisplay::Identifier>
Identifiers associated with the Affiliation.
50 51 52 53 |
# File 'lib/cocina_display/contributors/affiliation.rb', line 50 def identifiers @identifiers ||= Utils.flatten_nested_values(cocina) .pluck("identifier").flatten.compact_blank.map { |id| CocinaDisplay::Identifier.new(id) } end |
#name_components ⇒ Array<String>
All components of the Affiliation name as an array of strings.
58 59 60 |
# File 'lib/cocina_display/contributors/affiliation.rb', line 58 def name_components @name_components ||= Utils.flatten_nested_values(cocina).pluck("value").compact_blank end |
#ror ⇒ String?
ROR URI for the Affiliation, if present.
37 38 39 |
# File 'lib/cocina_display/contributors/affiliation.rb', line 37 def ror ror_identifier&.uri end |
#ror? ⇒ Boolean
Does this Affiliation have a ROR ID?
30 31 32 |
# File 'lib/cocina_display/contributors/affiliation.rb', line 30 def ror? ror_identifier.present? end |
#ror_id ⇒ String?
ROR ID for the Affiliation, if present.
44 45 46 |
# File 'lib/cocina_display/contributors/affiliation.rb', line 44 def ror_id ror_identifier&.identifier end |
#ror_identifier ⇒ CocinaDisplay::Identifier?
This will usually be the most general ROR ID, if multiple.
The first Identifier object that contains a ROR ID.
65 66 67 |
# File 'lib/cocina_display/contributors/affiliation.rb', line 65 def ror_identifier identifiers.find { |id| id.type == "ROR" } end |
#to_s ⇒ String?
String representation of the affiliation, using display name.
17 18 19 |
# File 'lib/cocina_display/contributors/affiliation.rb', line 17 def to_s display_name end |