Class: RubyOmx::Response
- Includes:
- ROXML
- Defined in:
- lib/ruby_omx/response.rb
Direct Known Subclasses
Class Method Summary collapse
-
.format(response) ⇒ Object
This is the factoryish method that is called!, not new.
- .parse_xml(response) ⇒ Object
Methods inherited from Node
#accessors, #as_hash, #initialize
Constructor Details
This class inherits a constructor from RubyOmx::Node
Class Method Details
.format(response) ⇒ Object
This is the factoryish method that is called!, not new
22 23 24 25 26 27 28 |
# File 'lib/ruby_omx/response.rb', line 22 def self.format(response) if response.content_type =~ /xml/ || response.body =~ /<?xml/ parse_xml(response) else response.body end end |
.parse_xml(response) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/ruby_omx/response.rb', line 30 def self.parse_xml(response) if [Net::HTTPClientError, Net::HTTPServerError].any? {|error| response.is_a? error } puts "ERROR: #{response} -- #{response.body}" return ResponseError.from_xml(response.body) else return self.from_xml(response.body) end end |