Class: Peddler::ResponseWrapper

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/peddler/response_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ResponseWrapper

Returns a new instance of ResponseWrapper.



12
13
14
# File 'lib/peddler/response_wrapper.rb', line 12

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



10
11
12
# File 'lib/peddler/response_wrapper.rb', line 10

def response
  @response
end

Instance Method Details

#documentObject



16
17
18
# File 'lib/peddler/response_wrapper.rb', line 16

def document
  Nokogiri::XML(body)
end

#next_tokenObject



27
28
29
30
# File 'lib/peddler/response_wrapper.rb', line 27

def next_token
  node = xml_payload.at_xpath('xmlns:NextToken')
  node.text if node
end

#xml_payloadObject



20
21
22
23
24
25
# File 'lib/peddler/response_wrapper.rb', line 20

def xml_payload
  root = document.root
  path = root.name.sub('Response', 'Result')

  root.xpath("xmlns:#{path}")
end