Class: CocinaDisplay::Contributors::Role
- Inherits:
-
Object
- Object
- CocinaDisplay::Contributors::Role
- Defined in:
- lib/cocina_display/contributors/role.rb
Overview
A role associated with a contributor.
Instance Attribute Summary collapse
-
#cocina ⇒ Object
readonly
Returns the value of attribute cocina.
Instance Method Summary collapse
-
#author? ⇒ Boolean
Does this role indicate the contributor is an author?.
-
#code ⇒ String?
A code associated with the role, e.g.
-
#display_str ⇒ String?
The name of the role.
-
#initialize(cocina) ⇒ Role
constructor
Initialize a Role object with Cocina structured data.
-
#publisher? ⇒ Boolean
Does this role indicate the contributor is a publisher?.
Constructor Details
#initialize(cocina) ⇒ Role
Initialize a Role object with Cocina structured data.
13 14 15 |
# File 'lib/cocina_display/contributors/role.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/role.rb', line 9 def cocina @cocina end |
Instance Method Details
#author? ⇒ Boolean
Does this role indicate the contributor is an author?
32 33 34 |
# File 'lib/cocina_display/contributors/role.rb', line 32 def display_str =~ /^(author|creator)/i end |
#code ⇒ String?
A code associated with the role, e.g. a MARC relator code.
26 27 28 |
# File 'lib/cocina_display/contributors/role.rb', line 26 def code cocina["code"] end |
#display_str ⇒ String?
The name of the role. Translates the MARC relator code if no value was present.
20 21 22 |
# File 'lib/cocina_display/contributors/role.rb', line 20 def display_str cocina["value"] || (Vocabularies::MARC_RELATOR[code] if marc_relator?) end |
#publisher? ⇒ Boolean
Does this role indicate the contributor is a publisher?
38 39 40 |
# File 'lib/cocina_display/contributors/role.rb', line 38 def publisher? display_str =~ /^publisher/i end |