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

Instance Method Details

#archived_website?Boolean

Is the object a web archive?

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


70
71
72
# File 'lib/cocina_display/concerns/forms.rb', line 70

def dataset?
  genres.include?("Dataset")
end

#extentsArray<String>

Extent of the object, such as “1 audiotape” or “1 map”.

Examples:

Oral history interview (sw705fr7011)

record.extents #=> ["1 audiotape", "1 transcript"]

Returns:

  • (Array<String>)


27
28
29
# File 'lib/cocina_display/concerns/forms.rb', line 27

def extents
  path("$.description.form..[?@.type == 'extent'].value").uniq
end

#formsArray<String>

Physical or digital forms of the object.

Examples:

GIS dataset (nz187ct8959)

record.forms #=> ["map", "optical disc", "electronic resource"]

Returns:

  • (Array<String>)


19
20
21
# File 'lib/cocina_display/concerns/forms.rb', line 19

def forms
  path("$.description.form..[?@.type == 'form'].value").uniq
end

#genresArray<String>

Genres of the object, capitalized for display.

Examples:

GIS dataset (nz187ct8959)

record.genres #=> ["Cartographic dataset", "Geospatial data", "Geographic information systems data"]

Returns:

  • (Array<String>)


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_searchArray<String>

Note:

These values are added for discovery in SearchWorks but not for display.

Genres of the object, with additional values added for search/faceting.

Returns:

  • (Array<String>)


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?

Returns:

  • (Boolean)


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_typesArray<String>

Resource types of the object, expressed in SearchWorks controlled vocabulary.

Returns:

  • (Array<String>)


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