Class: Dmm::Response

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

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



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

def initialize(response)
  @response =response
  # @body = Hash.from_xml(@response.body)
  # @body = @body["response"] if @body.key?("response")
  @body = XmlSimple.xml_in(@response.body)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



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

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

Instance Method Details

#codeObject



11
12
13
# File 'lib/dmm/api/response.rb', line 11

def code
  @response.code.to_i
end

#messageObject



15
16
17
# File 'lib/dmm/api/response.rb', line 15

def message
  @response.message
end