Class: CocinaDisplay::Forms::ResourceType
- Defined in:
- lib/cocina_display/forms/resource_type.rb
Overview
A Resource Type form associated with part or all of a Cocina object.
Instance Attribute Summary
Attributes inherited from Form
Instance Method Summary collapse
-
#flat_value ⇒ String
For self-deposit resource types, the flat value comprises primary and any subtypes.
-
#mods? ⇒ Boolean
Is this a MODS resource type?.
-
#stanford_self_deposit? ⇒ Boolean
Is this a Stanford self-deposit resource type?.
-
#to_s ⇒ String
Resource types are lowercased for display, except self-deposit types.
Methods inherited from Form
from_cocina, #initialize, #label, #type, #values
Constructor Details
This class inherits a constructor from CocinaDisplay::Forms::Form
Instance Method Details
#flat_value ⇒ String
For self-deposit resource types, the flat value comprises primary and any subtypes.
13 14 15 16 17 18 |
# File 'lib/cocina_display/forms/resource_type.rb', line 13 def flat_value return super unless stanford_self_deposit? return primary_type unless subtypes.any? "#{primary_type} (#{subtypes.join(", ")})" end |
#mods? ⇒ Boolean
Is this a MODS resource type?
29 30 31 |
# File 'lib/cocina_display/forms/resource_type.rb', line 29 def mods? source == "MODS resource types" end |
#stanford_self_deposit? ⇒ Boolean
Note:
These are handled separately when displayed.
Is this a Stanford self-deposit resource type?
23 24 25 |
# File 'lib/cocina_display/forms/resource_type.rb', line 23 def stanford_self_deposit? source == "Stanford self-deposit resource types" end |
#to_s ⇒ String
Resource types are lowercased for display, except self-deposit types.
7 8 9 |
# File 'lib/cocina_display/forms/resource_type.rb', line 7 def to_s stanford_self_deposit? ? flat_value : flat_value.downcase end |