Sha256: 899cad408f65a9edb786f37cdeef63c13d5c2d4eca2c588fc59c3dcfe2e806c8

Contents?: true

Size: 714 Bytes

Versions: 16

Compression:

Stored size: 714 Bytes

Contents

module ModsDisplay
  class Geo < Field
    def fields
      return [] unless geo_extensions.present?
      extensions = geo_extensions.map(&method(:process_geo_extension))
      [
        ModsDisplay::Values.new(
          label: I18n.t('mods_display.geo_extension'),
          values: extensions
        )
      ]
    end

    private

    def process_geo_extension(extension)
      rdf = Nokogiri::XML(extension.children.to_s)
      [
        rdf.xpath('//format').text[/format=(.*)$/, 1],
        rdf.xpath('//type').text[/#(.*)$/, 1]
      ].compact.join('; ')
    end

    def geo_extensions
      @geo_values ||= @values.select do |value|
        displayLabel(value) =~ /^geo:?$/
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mods_display-1.0.0.alpha4 lib/mods_display/fields/geo.rb
mods_display-1.0.0.alpha3 lib/mods_display/fields/geo.rb
mods_display-1.0.0.alpha2 lib/mods_display/fields/geo.rb
mods_display-1.0.0.alpha1 lib/mods_display/fields/geo.rb
mods_display-0.10.1 lib/mods_display/fields/geo.rb
mods_display-0.10.0 lib/mods_display/fields/geo.rb
mods_display-0.9.1 lib/mods_display/fields/geo.rb
mods_display-0.9.0 lib/mods_display/fields/geo.rb
mods_display-0.8.0 lib/mods_display/fields/geo.rb
mods_display-0.7.1 lib/mods_display/fields/geo.rb
mods_display-0.7.0 lib/mods_display/fields/geo.rb
mods_display-0.6.0 lib/mods_display/fields/geo.rb
mods_display-0.5.1 lib/mods_display/fields/geo.rb
mods_display-0.5.0 lib/mods_display/fields/geo.rb
mods_display-0.4.1 lib/mods_display/fields/geo.rb
mods_display-0.4.0 lib/mods_display/fields/geo.rb