Method: Peddler::Parser.new

Defined in:
lib/peddler/parser.rb

.new(res, encoding) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The inevitable-seeming messiness of massaging data produced by a motley army of Amazon developers



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/peddler/parser.rb', line 11

def new(res, encoding)
  # Don't parse if there's no body
  return res unless res.body

  if xml?(res)
    XMLResponseParser.new(res)
  else
    # Amazon returns a variety of content types for flat files, so we
    # simply assume that anything not XML is a flat file rather than code
    # defensively and check content type again.
    FlatFileParser.new(res, encoding)
  end
end