Sha256: d1d213495c1eb05e131cc45be02155a7002d6ec87ecb191500a8838cc06c61de

Contents?: true

Size: 783 Bytes

Versions: 4

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true

module ModsDisplay
  class Language < Field
    def fields
      return_fields = @stanford_mods_elements.map do |language_element|
        next unless language_element.respond_to?(:languageTerm)

        language_element.languageTerm.map do |term|
          next unless term.attributes['type'].respond_to?(:value) && term.attributes['type'].value == 'code'

          ModsDisplay::Values.new(
            label: displayLabel(language_element) || displayLabel(term) || I18n.t('mods_display.language'),
            values: [language_codes[element_text(term)]]
          )
        end.flatten.compact
      end.flatten.compact
      collapse_fields(return_fields)
    end

    private

    def language_codes
      SEARCHWORKS_LANGUAGES
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mods_display-1.6.3 lib/mods_display/fields/language.rb
mods_display-1.6.2 lib/mods_display/fields/language.rb
mods_display-1.6.1 lib/mods_display/fields/language.rb
mods_display-1.6.0 lib/mods_display/fields/language.rb