Class: Kickscraper::Api
- Inherits:
-
Object
show all
- Extended by:
- Connection
- Includes:
- Hashie::Extensions::Coercion
- Defined in:
- lib/kickscraper/api.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(blob) ⇒ Api
Returns a new instance of Api.
7
8
9
|
# File 'lib/kickscraper/api.rb', line 7
def initialize(blob)
@raw = blob
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
11
12
13
|
# File 'lib/kickscraper/api.rb', line 11
def method_missing(name)
@raw.send(name) if @raw.respond_to? name
end
|
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw.
5
6
7
|
# File 'lib/kickscraper/api.rb', line 5
def raw
@raw
end
|
Class Method Details
.coerce(raw) ⇒ Object
15
16
17
18
19
|
# File 'lib/kickscraper/api.rb', line 15
def self.coerce(raw)
a = self.new(raw)
self::do_coercion(a)
a
end
|
.do_coercion(instance) ⇒ Object
21
22
23
|
# File 'lib/kickscraper/api.rb', line 21
def self.do_coercion(instance)
self.key_coercions.each{ |k,v| instance.raw[k] = v.coerce(instance.raw[k]) }
end
|
Instance Method Details
#uid ⇒ Object
25
26
27
|
# File 'lib/kickscraper/api.rb', line 25
def uid
self.id == Kickscraper.client.user.id ? 'self' : self.id
end
|