Module: CocinaDisplay::Concerns::Forms
- Included in:
- CocinaDisplay::CocinaRecord
- Defined in:
- lib/cocina_display/concerns/forms.rb
Overview
Methods for extracting format/genre information from a Cocina object
Instance Method Summary collapse
-
#archived_website? ⇒ Boolean
Is the object a web archive?.
-
#cartographic? ⇒ Boolean
Is the object a cartographic resource?.
-
#dataset? ⇒ Boolean
Is the object a dataset?.
-
#extents ⇒ Array<String>
Extent of the object, such as “1 audiotape” or “1 map”.
-
#forms ⇒ Array<String>
Physical or digital forms of the object.
-
#genres ⇒ Array<String>
Genres of the object, capitalized for display.
-
#genres_search ⇒ Array<String>
Genres of the object, with additional values added for search/faceting.
-
#periodical? ⇒ Boolean
Is the object a periodical or serial?.
-
#resource_types ⇒ Array<String>
Resource types of the object, expressed in SearchWorks controlled vocabulary.
Instance Method Details
#archived_website? ⇒ Boolean
Is the object a web archive?
64 65 66 |
# File 'lib/cocina_display/concerns/forms.rb', line 64 def archived_website? genres.include?("Archived website") end |
#cartographic? ⇒ Boolean
Is the object a cartographic resource?
58 59 60 |
# File 'lib/cocina_display/concerns/forms.rb', line 58 def cartographic? resource_type_values.include?("cartographic") end |
#dataset? ⇒ Boolean
Is the object a dataset?
70 71 72 |
# File 'lib/cocina_display/concerns/forms.rb', line 70 def dataset? genres.include?("Dataset") end |
#extents ⇒ Array<String>
Extent of the object, such as “1 audiotape” or “1 map”.
27 28 29 |
# File 'lib/cocina_display/concerns/forms.rb', line 27 def extents path("$.description.form..[?@.type == 'extent'].value").uniq end |
#forms ⇒ Array<String>
Physical or digital forms of the object.
19 20 21 |
# File 'lib/cocina_display/concerns/forms.rb', line 19 def forms path("$.description.form..[?@.type == 'form'].value").uniq end |
#genres ⇒ Array<String>
Genres of the object, capitalized for display.
35 36 37 |
# File 'lib/cocina_display/concerns/forms.rb', line 35 def genres path("$.description.form..[?@.type == 'genre'].value").map(&:upcase_first).uniq end |
#genres_search ⇒ Array<String>
These values are added for discovery in SearchWorks but not for display.
Genres of the object, with additional values added for search/faceting.
42 43 44 45 46 47 48 |
# File 'lib/cocina_display/concerns/forms.rb', line 42 def genres_search genres.tap do |values| values << "Thesis/Dissertation" if values.include?("Thesis") values << "Conference proceedings" if values.include?("Conference publication") values << "Government document" if values.include?("Government publication") end.uniq end |
#periodical? ⇒ Boolean
Is the object a periodical or serial?
52 53 54 |
# File 'lib/cocina_display/concerns/forms.rb', line 52 def periodical? issuance_terms.include?("periodical") || issuance_terms.include?("serial") || frequency.any? end |
#resource_types ⇒ Array<String>
Resource types of the object, expressed in SearchWorks controlled vocabulary.
9 10 11 12 13 |
# File 'lib/cocina_display/concerns/forms.rb', line 9 def resource_types mapped_values = resource_type_values.flat_map { |resource_type| searchworks_resource_type(resource_type) } mapped_values << "Dataset" if dataset? mapped_values.uniq end |