Class: CocinaDisplay::Titles::TitleValue
- Inherits:
-
Parallel::ParallelValue
- Object
- Parallel::ParallelValue
- CocinaDisplay::Titles::TitleValue
- Defined in:
- lib/cocina_display/titles/title_value.rb
Overview
A Title associated with an item in a single language.
Constant Summary collapse
- PART_TYPES =
Part types for structured titles.
["main title", "nonsorting characters", "part name", "part number", "subtitle"].freeze
Constants inherited from Parallel::ParallelValue
Parallel::ParallelValue::PARALLEL_TYPES
Instance Attribute Summary
Attributes inherited from Parallel::ParallelValue
Instance Method Summary collapse
-
#display_title ⇒ String?
The long form of the title, without trailing punctuation.
-
#full_title ⇒ String?
The long form of the title, including subtitle, part name, etc.
-
#label ⇒ String?
Custom label used when displaying the title, if any.
-
#short_title ⇒ String?
The short form of the title, without subtitle, part name, etc.
-
#sort_title ⇒ String
A string value for sorting by title.
-
#to_s ⇒ String?
The string representation of the title, for display.
Methods inherited from Parallel::ParallelValue
#display?, #initialize, #language, #main_value, #own_type, #own_typed?, #primary?, #siblings, #status, #translated?, #transliterated?, #type, #typed?, #vernacular?
Constructor Details
This class inherits a constructor from CocinaDisplay::Parallel::ParallelValue
Instance Method Details
#display_title ⇒ String?
This corresponds to the entire MARC 245 field.
The long form of the title, without trailing punctuation.
44 45 46 |
# File 'lib/cocina_display/titles/title_value.rb', line 44 def display_title display_title_str.presence || cocina["value"] end |
#full_title ⇒ String?
This corresponds to the entire MARC 245 field.
The long form of the title, including subtitle, part name, etc.
37 38 39 |
# File 'lib/cocina_display/titles/title_value.rb', line 37 def full_title full_title_str.presence || cocina["value"] end |
#label ⇒ String?
Custom label used when displaying the title, if any.
14 15 16 |
# File 'lib/cocina_display/titles/title_value.rb', line 14 def label display_label || type_label end |
#short_title ⇒ String?
This corresponds to the “short title” in MODS XML, or MARC 245$a only.
The short form of the title, without subtitle, part name, etc.
29 30 31 |
# File 'lib/cocina_display/titles/title_value.rb', line 29 def short_title short_title_str.presence || cocina["value"] end |
#sort_title ⇒ String
A string value for sorting by title. Ignores punctuation, leading/trailing spaces, and non-sorting characters. If no title is present, returns a high Unicode value so it sorts last.
52 53 54 55 56 57 58 59 60 |
# File 'lib/cocina_display/titles/title_value.rb', line 52 def sort_title return "\u{10FFFF}" unless full_title full_title[nonsorting_chars_str.length..] .unicode_normalize(:nfd) # Prevent accents being stripped .gsub(/[[:punct:]]*/, "") .gsub(/\W{2,}/, " ") # Collapse whitespace after removing punctuation .strip end |
#to_s ⇒ String?
The string representation of the title, for display.
21 22 23 |
# File 'lib/cocina_display/titles/title_value.rb', line 21 def to_s display_title end |