Class: Covetous::Shen

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/covetous/shen.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url_option, extra_options = {}) ⇒ Shen

Returns a new instance of Shen.



7
8
9
# File 'lib/covetous/shen.rb', line 7

def initialize(url_option, extra_options={})
  @response = self.class.get @url
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/covetous/shen.rb', line 11

def method_missing(name, *args, &block)
  camelcased_key = name.to_s.camelize(:lower)
  if @response.has_key?(camelcased_key)
    @response[camelcased_key]
  else
    super
  end
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/covetous/shen.rb', line 5

def response
  @response
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/covetous/shen.rb', line 5

def url
  @url
end