Sha256: 6508884352c41a5538c7df0dab3d5587f47162512be6ea5d6ba672a91d584fcb

Contents?: true

Size: 972 Bytes

Versions: 4

Compression:

Stored size: 972 Bytes

Contents

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

4 entries across 4 versions & 1 rubygems

Version Path
geoblacklight-2.4.0 lib/geoblacklight/reference.rb
geoblacklight-2.3.0 lib/geoblacklight/reference.rb
geoblacklight-2.2.1 lib/geoblacklight/reference.rb
geoblacklight-2.2.0 lib/geoblacklight/reference.rb