Sha256: be05dacf0254af1597d292e68f19fdba8292fa714fcc78c70414d6e65beca458

Contents?: true

Size: 1002 Bytes

Versions: 20

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true
module Geoblacklight
  ##
  # Parses an array of dct_references to create useful reference information
  class Reference
    attr_reader :reference

    ##
    # Initializes a Reference object using an Array
    # @param [Array] reference
    def initialize(reference)
      @reference = reference
    end

    ##
    # The endpoint URL for a Geoblacklight::Reference
    # @return [String]
    def endpoint
      @reference[1]
    end

    ##
    # Lookups the type from the Constants::URI using the reference's URI
    # @return [Symbol]
    def type
      Geoblacklight::Constants::URI.key(uri)
    end

    ##
    # Creates a hash, using its type as key and endpoint as value
    # @return [Hash]
    def to_hash
      { type => endpoint }
    end

    private

    ##
    # The URI used for this instance's creation
    # Remove any trailing slashes
    # @return [String]
    def uri
      @reference[0].sub(/(\/)+$/, '') if @reference[0].present?
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
geoblacklight-3.8.1 lib/geoblacklight/reference.rb
geoblacklight-3.8.0 lib/geoblacklight/reference.rb
geoblacklight-4.0.0 lib/geoblacklight/reference.rb
geoblacklight-4.0.0.pre.rc3 lib/geoblacklight/reference.rb
geoblacklight-3.7.0 lib/geoblacklight/reference.rb
geoblacklight-4.0.0.pre.rc2 lib/geoblacklight/reference.rb
geoblacklight-4.0.0.pre.rc1 lib/geoblacklight/reference.rb
geoblacklight-3.6.0 lib/geoblacklight/reference.rb
geoblacklight-3.5.0 lib/geoblacklight/reference.rb
geoblacklight-4.0.0.pre.alpha.3 lib/geoblacklight/reference.rb
geoblacklight-4.0.0.pre.alpha.2 lib/geoblacklight/reference.rb
geoblacklight-4.0.0.pre.alpha.1 lib/geoblacklight/reference.rb
geoblacklight-4.0.0.pre.alpha lib/geoblacklight/reference.rb
geoblacklight-3.4.0 lib/geoblacklight/reference.rb
geoblacklight-3.3.1 lib/geoblacklight/reference.rb
geoblacklight-3.3.0 lib/geoblacklight/reference.rb
geoblacklight-3.2.0 lib/geoblacklight/reference.rb
geoblacklight-3.1.0 lib/geoblacklight/reference.rb
geoblacklight-3.0.1 lib/geoblacklight/reference.rb
geoblacklight-3.0.0 lib/geoblacklight/reference.rb