Module: Scrunchie::XML
- Defined in:
- lib/scrunchie.rb
Class Method Summary collapse
- .convert_to_hash(body) ⇒ Object
-
.parse(body) ⇒ Object
Attemps to parse the body, and rescue the ParseError to do the right thing.
Class Method Details
.convert_to_hash(body) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/scrunchie.rb', line 83 def convert_to_hash(body) if body.start_with?("Error") return { "Error" => body } else return { "Other" => body } end end |
.parse(body) ⇒ Object
Attemps to parse the body, and rescue the ParseError to do the right thing
77 78 79 80 81 |
# File 'lib/scrunchie.rb', line 77 def parse(body) MultiXml.parse(body) rescue MultiXml::ParseError convert_to_hash(body) end |