Module: CocinaDisplay::Concerns::Subjects
- Included in:
- CocinaDisplay::CocinaRecord, RelatedResource
- Defined in:
- lib/cocina_display/concerns/subjects.rb
Overview
Methods for extracting and formatting subject information.
Instance Method Summary collapse
-
#subject_all ⇒ Array<String>
Combination of all subject values for searching.
-
#subject_all_display ⇒ Array<String>
Combination of all subjects with nested values concatenated for display.
-
#subject_display_data ⇒ Array<DisplayData>
Subject data to be rendered for display.
-
#subject_genres ⇒ Array<String>
All unique subject values that are genres.
-
#subject_names ⇒ Array<String>
All unique subject values that are names of entities.
-
#subject_occupations ⇒ Array<String>
All unique subject values that are occupations.
-
#subject_other ⇒ Array<String>
Combination of occupation, name, and title subject values for searching.
-
#subject_places ⇒ Array<String>
All unique subject values that are named geographic places.
-
#subject_temporal ⇒ Array<String>
All unique subject values that are date/time info.
-
#subject_temporal_genre ⇒ Array<String>
Combination of temporal and genre subject values for searching.
-
#subject_titles ⇒ Array<String>
All unique subject values that are titles.
-
#subject_topics ⇒ Array<String>
All unique subject values that are topics.
-
#subject_topics_other ⇒ Array<String>
Combination of topic, occupation, name, and title subject values for searching.
Instance Method Details
#subject_all ⇒ Array<String>
Combination of all subject values for searching.
54 55 56 |
# File 'lib/cocina_display/concerns/subjects.rb', line 54 def subject_all subject_topics_other + subject_temporal_genre + subject_places end |
#subject_all_display ⇒ Array<String>
Combination of all subjects with nested values concatenated for display.
86 87 88 |
# File 'lib/cocina_display/concerns/subjects.rb', line 86 def subject_all_display all_subjects.map(&:to_s).uniq end |
#subject_display_data ⇒ Array<DisplayData>
Subject data to be rendered for display. Uses the concatenated form for structured subject values.
94 95 96 |
# File 'lib/cocina_display/concerns/subjects.rb', line 94 def subject_display_data CocinaDisplay::DisplayData.from_objects(all_subjects - classification_subjects - genre_subjects - coordinate_subjects) end |
#subject_genres ⇒ Array<String>
All unique subject values that are genres.
13 14 15 |
# File 'lib/cocina_display/concerns/subjects.rb', line 13 def subject_genres subject_values.filter { |s| s.type == "genre" }.map(&:to_s).uniq end |
#subject_names ⇒ Array<String>
Multiple types are handled: person, family, organization, conference, etc.
All unique subject values that are names of entities.
45 46 47 |
# File 'lib/cocina_display/concerns/subjects.rb', line 45 def subject_names subject_values.filter { |s| s.is_a? CocinaDisplay::Subjects::NameSubjectValue }.map(&:to_s).uniq end |
#subject_occupations ⇒ Array<String>
All unique subject values that are occupations.
31 32 33 |
# File 'lib/cocina_display/concerns/subjects.rb', line 31 def subject_occupations subject_values.filter { |s| s.type == "occupation" }.map(&:to_s).uniq end |
#subject_other ⇒ Array<String>
Combination of occupation, name, and title subject values for searching.
71 72 73 |
# File 'lib/cocina_display/concerns/subjects.rb', line 71 def subject_other subject_occupations + subject_names + subject_titles end |
#subject_places ⇒ Array<String>
All unique subject values that are named geographic places.
37 38 39 |
# File 'lib/cocina_display/concerns/subjects.rb', line 37 def subject_places place_subject_values.map(&:to_s).uniq end |
#subject_temporal ⇒ Array<String>
All unique subject values that are date/time info.
25 26 27 |
# File 'lib/cocina_display/concerns/subjects.rb', line 25 def subject_temporal subject_values.filter { |s| s.type == "time" }.map(&:to_s).uniq end |
#subject_temporal_genre ⇒ Array<String>
Combination of temporal and genre subject values for searching.
79 80 81 |
# File 'lib/cocina_display/concerns/subjects.rb', line 79 def subject_temporal_genre subject_temporal + subject_genres end |
#subject_titles ⇒ Array<String>
All unique subject values that are titles.
19 20 21 |
# File 'lib/cocina_display/concerns/subjects.rb', line 19 def subject_titles subject_values.filter { |s| s.type == "title" }.map(&:to_s).uniq end |
#subject_topics ⇒ Array<String>
All unique subject values that are topics.
7 8 9 |
# File 'lib/cocina_display/concerns/subjects.rb', line 7 def subject_topics subject_values.filter { |s| s.type == "topic" }.map(&:to_s).uniq end |
#subject_topics_other ⇒ Array<String>
Combination of topic, occupation, name, and title subject values for searching.
62 63 64 |
# File 'lib/cocina_display/concerns/subjects.rb', line 62 def subject_topics_other subject_topics + subject_other end |