Sha256: 2290e72821802163be2f9b1e3cc78bb5e62d9c3fad460e4508445a9b2ef22793
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 KB
Contents
class ModsDisplay::Title < ModsDisplay::Field def fields return_values = [] @value.each do |val| if displayForm(val) return_values << ModsDisplay::Values.new(:label => displayLabel(val) || title_label(val), :values => [displayForm(val).text]) else nonSort = nil title = nil subTitle = nil nonSort = val.nonSort.text.strip unless val.nonSort.text.strip.empty? title = val.title.text.strip unless val.title.text.strip.empty? subTitle = val.subTitle.text unless val.subTitle.text.strip.empty? preSubTitle = [nonSort, title].compact.join(" ") preSubTitle = nil if preSubTitle.strip.empty? preParts = [preSubTitle, subTitle].compact.join(" : ") preParts = nil if preParts.strip.empty? parts = val.children.select do |child| ["partName", "partNumber"].include?(child.name) end.map do |child| child.text end.compact.join(", ") parts = nil if parts.strip.empty? return_values << ModsDisplay::Values.new(:label => displayLabel(val) || title_label(val), :values => [[preParts, parts].compact.join(". ")]) end end return_values end private def title_label(element) if (element.attributes["type"].respond_to?(:value) and title_labels.has_key?(element.attributes["type"].value)) return title_labels[element.attributes["type"].value] end "Title" end def title_labels {"abbreviated" => "Abbreviated title", "translated" => "Translated title", "alternative" => "Alternative title", "uniform" => "Uniform title"} end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mods_display-0.0.3 | lib/mods_display/fields/title.rb |
mods_display-0.0.2 | lib/mods_display/fields/title.rb |
mods_display-0.0.1 | lib/mods_display/fields/title.rb |