Class: Rea::WorkKey

Inherits:
Object
  • Object
show all
Defined in:
lib/rea/work_key.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider, identifier) ⇒ WorkKey

Returns a new instance of WorkKey.



7
8
9
# File 'lib/rea/work_key.rb', line 7

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

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



5
6
7
# File 'lib/rea/work_key.rb', line 5

def identifier
  @identifier
end

#providerObject (readonly)

Returns the value of attribute provider.



4
5
6
# File 'lib/rea/work_key.rb', line 4

def provider
  @provider
end

Class Method Details

.parse(str) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rea/work_key.rb', line 11

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

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



19
20
21
# File 'lib/rea/work_key.rb', line 19

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

#to_ruby_literalObject



28
29
30
# File 'lib/rea/work_key.rb', line 28

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

#to_sObject



24
25
26
# File 'lib/rea/work_key.rb', line 24

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