Sha256: 03a321a90dc2930bc085c87073a5222433e74f940dbf4f8691aa5cb55ff915bb

Contents?: true

Size: 420 Bytes

Versions: 3

Compression:

Stored size: 420 Bytes

Contents

# frozen_string_literal: true

require 'stringio'

module XmlHasher
  class Parser
    def initialize(options = {})
      @options = options
    end

    def parse(xml)
      handler = Handler.new(@options)
      Ox.sax_parse(handler, convert(xml))
      handler.to_hash
    end

    private

    def convert(xml)
      xml.respond_to?(:read) || xml.respond_to?(:readpartial) ? xml : StringIO.new(xml)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xmlhasher-1.0.7 lib/xmlhasher/parser.rb
xmlhasher-1.0.6 lib/xmlhasher/parser.rb
xmlhasher-1.0.5 lib/xmlhasher/parser.rb