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

Instance Method Details

#subject_allArray<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_displayArray<String>

Combination of all subjects with nested values concatenated for display.

Returns:

  • (Array<String>)

See Also:

  • Subject#to_s


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_dataArray<DisplayData>

Subject data to be rendered for display. Uses the concatenated form for structured subject values.

Returns:

See Also:

  • Subject#to_s


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

All unique subject values that are genres.

Returns:

  • (Array<String>)


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

Note:

Multiple types are handled: person, family, organization, conference, etc.

All unique subject values that are names of entities.

Returns:

  • (Array<String>)

See Also:

  • NameSubjectValue


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

All unique subject values that are occupations.

Returns:

  • (Array<String>)


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

Combination of occupation, name, and title subject values for searching.

Returns:

  • (Array<String>)

See Also:



71
72
73
# File 'lib/cocina_display/concerns/subjects.rb', line 71

def subject_other
  subject_occupations + subject_names + subject_titles
end

#subject_placesArray<String>

All unique subject values that are named geographic places.

Returns:

  • (Array<String>)


37
38
39
# File 'lib/cocina_display/concerns/subjects.rb', line 37

def subject_places
  place_subject_values.map(&:to_s).uniq
end

#subject_temporalArray<String>

All unique subject values that are date/time info.

Returns:

  • (Array<String>)


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

Combination of temporal and genre subject values for searching.

Returns:

  • (Array<String>)

See Also:



79
80
81
# File 'lib/cocina_display/concerns/subjects.rb', line 79

def subject_temporal_genre
  subject_temporal + subject_genres
end

#subject_titlesArray<String>

All unique subject values that are titles.

Returns:

  • (Array<String>)


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

All unique subject values that are topics.

Returns:

  • (Array<String>)


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

Combination of topic, occupation, name, and title subject values for searching.

Returns:

  • (Array<String>)

See Also:



62
63
64
# File 'lib/cocina_display/concerns/subjects.rb', line 62

def subject_topics_other
  subject_topics + subject_other
end