lib/sucker/response.rb in sucker-0.7.1 vs lib/sucker/response.rb in sucker-0.8.0
- old
+ new
@@ -1,27 +1,25 @@
module Sucker
# A Nokogiri-driven wrapper around the cURL response
class Response
- attr_accessor :body, :code, :time, :xml
+ attr_accessor :body, :code, :time
def initialize(curl)
self.body = curl.body_str
self.code = curl.response_code
self.time = curl.total_time
end
- # Queries an xpath and returns a collection of hashified matches
+ # Queries an xpath and returns result as an array of hashes
def node(path)
xml.xpath("//xmlns:#{path}").map { |node| strip_content(node.to_hash[path]) }
end
- # Hashifies XML document or node
+ # Parses the response into a simple hash
def to_hash
strip_content(xml.to_hash)
end
-
- alias :to_h :to_hash
# The XML document
def xml
@xml ||= Nokogiri::XML(body)
end