Sha256: 1e86bae9c300642c4fa5ba03e1f2fd00636886216be9ac5330d3254a74d14a99

Contents?: true

Size: 591 Bytes

Versions: 6

Compression:

Stored size: 591 Bytes

Contents

# frozen_string_literal: true

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

module Peddler
  # @!visibility 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

6 entries across 6 versions & 1 rubygems

Version Path
peddler-2.4.5 lib/peddler/xml_parser.rb
peddler-2.4.4 lib/peddler/xml_parser.rb
peddler-2.4.3 lib/peddler/xml_parser.rb
peddler-2.4.1 lib/peddler/xml_parser.rb
peddler-2.4.0 lib/peddler/xml_parser.rb
peddler-2.3.0 lib/peddler/xml_parser.rb