Class: Yahoo::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/yahoo/api/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
10
# File 'lib/yahoo/api/response.rb', line 5

def initialize(response)
  @response =response
  body = @response.body
  body = body[9..(body.rindex(")")-1)] if body.include?("callback(")
  @body = JSON.parse(body)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



20
21
22
23
24
25
26
# File 'lib/yahoo/api/response.rb', line 20

def method_missing(name, *args, &block)
  if @body.respond_to?(name)
    @body.send(name, *args, &block)
  else
    super
  end
end

Instance Method Details

#codeObject



12
13
14
# File 'lib/yahoo/api/response.rb', line 12

def code
  @response.code.to_i
end

#messageObject



16
17
18
# File 'lib/yahoo/api/response.rb', line 16

def message
  @response.message
end