lib/mods_display/fields/language.rb in mods_display-0.3.3 vs lib/mods_display/fields/language.rb in mods_display-0.3.4

- old
+ new

@@ -1,21 +1,23 @@ -class ModsDisplay::Language < ModsDisplay::Field - def fields - return_fields = @values.map do |value| - if value.respond_to?(:languageTerm) +module ModsDisplay + class Language < Field + def fields + return_fields = @values.map do |value| + next unless value.respond_to?(:languageTerm) value.languageTerm.map do |term| - if term.attributes["type"].respond_to?(:value) and term.attributes["type"].value == "code" - ModsDisplay::Values.new(:label => displayLabel(value) || displayLabel(term) || I18n.t('mods_display.language'), :values => [displayForm(value) || language_codes[term.text]].flatten) - end + next unless term.attributes['type'].respond_to?(:value) && term.attributes['type'].value == 'code' + ModsDisplay::Values.new( + label: displayLabel(value) || displayLabel(term) || I18n.t('mods_display.language'), + values: [displayForm(value) || language_codes[term.text]].flatten + ) end.flatten.compact - end - end.flatten.compact - collapse_fields(return_fields) - end + end.flatten.compact + collapse_fields(return_fields) + end - private + private - def language_codes - SEARCHWORKS_LANGUAGES + def language_codes + SEARCHWORKS_LANGUAGES + end end - -end \ No newline at end of file +end