Module: Stanford::Mods::Title
- Included in:
- Record
- Defined in:
- lib/stanford-mods/concerns/title.rb
Instance Method Summary collapse
-
#sw_addl_titles ⇒ Array<String>
this includes all titles except.
-
#sw_full_title(title_info = first_title_info_node, sortable: false) ⇒ String
Searchworks requires that the MODS has a ‘//titleInfo/title’.
-
#sw_short_title ⇒ String
Value for title_245a_search field.
-
#sw_sort_title ⇒ String
Returns a sortable version of the main title.
-
#sw_title_display ⇒ String
like sw_full_title without trailing ,/;:.
- #title_parts ⇒ Object
Instance Method Details
#sw_addl_titles ⇒ Array<String>
this includes all titles except
67 68 69 |
# File 'lib/stanford-mods/concerns/title.rb', line 67 def sw_addl_titles (full_titles - Array(first_title_info_node&.full_title)).reject(&:blank?) end |
#sw_full_title(title_info = first_title_info_node, sortable: false) ⇒ String
Searchworks requires that the MODS has a ‘//titleInfo/title’
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/stanford-mods/concerns/title.rb', line 11 def sw_full_title(title_info = first_title_info_node, sortable: false) return unless title_info&.children&.any? title = title_info.title&.text&.strip return if title.nil? || title.empty? title = '' previous_element = nil title_info.children.select { |value| title_parts.include? value.name }.each do |value| next if value.name == 'nonSort' && sortable str = value.text.strip next if str.empty? delimiter = if title.empty? || title.end_with?(' ') nil elsif previous_element&.name == 'nonSort' && title.end_with?('-', '\'') nil elsif title.end_with?('.', ',', ':', ';') ' ' elsif value.name == 'subTitle' ' : ' elsif value.name == 'partName' && previous_element.name == 'partNumber' ', ' elsif value.name == 'partNumber' || value.name == 'partName' '. ' else ' ' end title += delimiter if delimiter title += str previous_element = value end title += "." unless title =~ /\s*[[:punct:]]$/ title.strip end |
#sw_short_title ⇒ String
Returns value for title_245a_search field.
5 6 7 |
# File 'lib/stanford-mods/concerns/title.rb', line 5 def sw_short_title short_titles&.compact&.reject(&:empty?)&.first end |
#sw_sort_title ⇒ String
Returns a sortable version of the main title
73 74 75 76 |
# File 'lib/stanford-mods/concerns/title.rb', line 73 def sw_sort_title val = sw_full_title(sortable: true) || '' val.gsub(/[[:punct:]]*/, '').squeeze(" ").strip end |
#sw_title_display ⇒ String
like sw_full_title without trailing ,/;:. spec from solrmarc-sw sw_index.properties
title_display = custom, removeTrailingPunct(245abdefghijklmnopqrstuvwxyz, [\\\\,/;:], ([A-Za-z]{4}|[0-9]{3}|\\)|\\,))
61 62 63 |
# File 'lib/stanford-mods/concerns/title.rb', line 61 def sw_title_display sw_full_title&.sub(/[\.,;:\/\\]+$/, '')&.strip end |
#title_parts ⇒ Object
53 54 55 |
# File 'lib/stanford-mods/concerns/title.rb', line 53 def title_parts %w[nonSort title subTitle partName partNumber] end |