Sha256: a96fa378db68f320f07918f9a9e922627db6b7b5cde41e8d69b58dc6ea79e10c

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

module ModsDisplay
  class Identifier < Field
    def fields
      return_fields = @values.map do |value|
        ModsDisplay::Values.new(label: displayLabel(value) || identifier_label(value), values: [element_text(value)])
      end
      collapse_fields(return_fields)
    end

    private

    def identifier_label(element)
      if element.attributes['type'].respond_to?(:value)
        return identifier_labels[element.attributes['type'].value] || "#{element.attributes['type'].value}:"
      end

      I18n.t('mods_display.identifier')
    end

    def identifier_labels
      { 'local' => I18n.t('mods_display.identifier'),
        'isbn' => I18n.t('mods_display.isbn'),
        'issn' => I18n.t('mods_display.issn'),
        'issn-l' => I18n.t('mods_display.issn'),
        'doi' => I18n.t('mods_display.doi'),
        'hdl' => I18n.t('mods_display.handle'),
        'isrc' => I18n.t('mods_display.isrc'),
        'ismn' => I18n.t('mods_display.ismn'),
        'issue number' => I18n.t('mods_display.issue_number'),
        'lccn' => I18n.t('mods_display.lccn'),
        'oclc' => I18n.t('mods_display.oclc'),
        'matrix number' => I18n.t('mods_display.matrix_number'),
        'music publisher' => I18n.t('mods_display.music_publisher'),
        'music plate' => I18n.t('mods_display.music_plate'),
        'sici' => I18n.t('mods_display.sici'),
        'upc' => I18n.t('mods_display.upc'),
        'videorecording identifier' => I18n.t('mods_display.videorecording_identifier'),
        'stock number' => I18n.t('mods_display.stock_number') }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mods_display-1.3.1 lib/mods_display/fields/identifier.rb
mods_display-1.3.0 lib/mods_display/fields/identifier.rb
mods_display-1.2.1 lib/mods_display/fields/identifier.rb
mods_display-1.2.0 lib/mods_display/fields/identifier.rb
mods_display-1.1.0 lib/mods_display/fields/identifier.rb