Class: Yahoo::Response
- Inherits:
-
Object
show all
- Defined in:
- lib/yahoo/api/response.rb
Instance Method Summary
collapse
Constructor Details
#initialize(response, format) ⇒ Response
Returns a new instance of Response.
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/yahoo/api/response.rb', line 5
def initialize(response,format)
@response =response
body = @response.body
if format == "json"
body = body[9..(body.rindex(")")-1)] if body.include?("callback(")
@body = JSON.parse(body)
else
@body = Hash.from_xml(body)
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/yahoo/api/response.rb', line 24
def method_missing(name, *args, &block)
if @body.respond_to?(name)
@body.send(name, *args, &block)
else
super
end
end
|
Instance Method Details
#code ⇒ Object
16
17
18
|
# File 'lib/yahoo/api/response.rb', line 16
def code
@response.code.to_i
end
|
#message ⇒ Object
20
21
22
|
# File 'lib/yahoo/api/response.rb', line 20
def message
@response.message
end
|