Module: CocinaDisplay::Concerns::Subjects
- Included in:
- CocinaDisplay::CocinaRecord
- 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_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 describe 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.
57 58 59 |
# File 'lib/cocina_display/concerns/subjects.rb', line 57 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.
89 90 91 |
# File 'lib/cocina_display/concerns/subjects.rb', line 89 def subject_all_display subjects.map(&:display_str).uniq end |
#subject_genres ⇒ Array<String>
All unique subject values that are genres.
16 17 18 |
# File 'lib/cocina_display/concerns/subjects.rb', line 16 def subject_genres subject_values.filter { |s| s.type == "genre" }.map(&:display_str).uniq end |
#subject_names ⇒ Array<String>
Multiple types are handled: person, family, organization, conference, etc.
All unique subject values that are names of entities.
48 49 50 |
# File 'lib/cocina_display/concerns/subjects.rb', line 48 def subject_names subject_values.filter { |s| s.is_a? CocinaDisplay::Subjects::NameSubjectValue }.map(&:display_str).uniq end |
#subject_occupations ⇒ Array<String>
All unique subject values that are occupations.
34 35 36 |
# File 'lib/cocina_display/concerns/subjects.rb', line 34 def subject_occupations subject_values.filter { |s| s.type == "occupation" }.map(&:display_str).uniq end |
#subject_other ⇒ Array<String>
Combination of occupation, name, and title subject values for searching.
74 75 76 |
# File 'lib/cocina_display/concerns/subjects.rb', line 74 def subject_other subject_occupations + subject_names + subject_titles end |
#subject_places ⇒ Array<String>
All unique subject values that describe geographic places.
40 41 42 |
# File 'lib/cocina_display/concerns/subjects.rb', line 40 def subject_places subject_values.filter(&:place?).map(&:display_str).uniq end |
#subject_temporal ⇒ Array<String>
All unique subject values that are date/time info.
28 29 30 |
# File 'lib/cocina_display/concerns/subjects.rb', line 28 def subject_temporal subject_values.filter { |s| s.type == "time" }.map(&:display_str).uniq end |
#subject_temporal_genre ⇒ Array<String>
Combination of temporal and genre subject values for searching.
82 83 84 |
# File 'lib/cocina_display/concerns/subjects.rb', line 82 def subject_temporal_genre subject_temporal + subject_genres end |
#subject_titles ⇒ Array<String>
All unique subject values that are titles.
22 23 24 |
# File 'lib/cocina_display/concerns/subjects.rb', line 22 def subject_titles subject_values.filter { |s| s.type == "title" }.map(&:display_str).uniq end |
#subject_topics ⇒ Array<String>
All unique subject values that are topics.
10 11 12 |
# File 'lib/cocina_display/concerns/subjects.rb', line 10 def subject_topics subject_values.filter { |s| s.type == "topic" }.map(&:display_str).uniq end |
#subject_topics_other ⇒ Array<String>
Combination of topic, occupation, name, and title subject values for searching.
65 66 67 |
# File 'lib/cocina_display/concerns/subjects.rb', line 65 def subject_topics_other subject_topics + subject_other end |