Sha256: fece5a4cf2b1410920c21fba86f2b347518c15b4bd3256cbb3fefeb179fdf866

Contents?: true

Size: 491 Bytes

Versions: 1

Compression:

Stored size: 491 Bytes

Contents

require 'delegate'
require 'multi_xml'

module Peddler
  # @api private
  class XMLParser < SimpleDelegator
    def next_token
      parse.fetch('NextToken', false)
    end

    def parse
      @result ||= find_result
    end

    def xml
      MultiXml.parse(body)
    end

    def valid?
      headers['Content-Length'].to_i == body.size if headers['Content-Length']
    end

    private

    def find_result
      xml.values[0].find { |k, v| k.include?('Result') }.last
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
peddler-0.7.7 lib/peddler/xml_parser.rb