Class: Craigslist::API::ResponseParser
- Inherits:
-
Object
- Object
- Craigslist::API::ResponseParser
- Defined in:
- lib/craigslist/api/response_parser.rb
Overview
Turns the RSS document returned by validate/post into a ResultSet.
Element lookups use the literal prefixed names as they appear on the wire rather than XPath namespace resolution, which REXML handles awkwardly when a default namespace is in play.
Constant Summary collapse
- UPLOAD_ID_PREFIX =
Prefix craigslist puts on the channel description in post mode.
"upload-id:"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(root, raw = nil) ⇒ ResponseParser
constructor
A new instance of ResponseParser.
- #result_set ⇒ ResultSet
Constructor Details
#initialize(root, raw = nil) ⇒ ResponseParser
Returns a new instance of ResponseParser.
37 38 39 40 |
# File 'lib/craigslist/api/response_parser.rb', line 37 def initialize(root, raw = nil) @root = root @raw = raw end |
Class Method Details
.parse(xml) ⇒ ResultSet
20 21 22 23 24 25 26 |
# File 'lib/craigslist/api/response_parser.rb', line 20 def parse(xml) document = build(xml) root = document.root raise ParseError, "response contained no root element" if root.nil? new(root, xml.to_s).result_set end |