Sha256: 4d8f305fa767c1863f9235fa4448a232a30346053369e7532ad46a04d05a1698

Contents?: true

Size: 578 Bytes

Versions: 2

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

require 'delegate'
require 'dig_rb'
require 'forwardable'
require 'peddler/headers'
require 'multi_xml'

module Peddler
  # @api private
  class XMLParser < SimpleDelegator
    extend Forwardable
    include Headers

    def_delegator :parse, :dig

    def parse
      @data ||= find_data
    end

    def xml
      MultiXml.parse(body)
    end

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

    private

    def find_data
      raise NotImplementedError
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
peddler-1.6.5 lib/peddler/xml_parser.rb
peddler-1.6.4 lib/peddler/xml_parser.rb