Sha256: bde6ead252d13c897c4148742ed9ce8f9c3ee6e2180a69d0ca7a5a0f86a4ca4b

Contents?: true

Size: 661 Bytes

Versions: 1

Compression:

Stored size: 661 Bytes

Contents

module Rea
  class WorkKey

    attr_reader :provider
    attr_reader :identifier

    def initialize(provider, identifier)
      @provider, @identifier = provider, identifier
    end

    def self.parse(str)
      return str if str.is_a?(WorkKey)
      unless str.strip =~ /^([a-z]+):\/\/(.+)$/
        raise ArgumentError, "Invalid work key #{str}"
      end
      WorkKey.new($1, $2)
    end

    def ==(other)
      other.is_a?(WorkKey) and other.to_s == to_s
    end
    alias :eql? :==

    def to_s
      "#{provider}://#{identifier}"
    end

    def to_ruby_literal
      "Rea::WorkKey(#{to_s.inspect})"
    end

  end # class WorkKey
end # module Rea

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rea-0.0.1 lib/rea/work_key.rb