Sha256: 5102a591905e8d111e30eccdf8be7b5d1017f6e173732fd8c3104c5f04818657

Contents?: true

Size: 583 Bytes

Versions: 2

Compression:

Stored size: 583 Bytes

Contents

# frozen_string_literal: true

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

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

    def_delegator :parse, :dig

    def data
      @data ||= find_data
    end

    alias parse data

    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-2.1.1 lib/peddler/xml_parser.rb
peddler-2.1.0 lib/peddler/xml_parser.rb