Method: XMLMunger::Parser#initialize

Defined in:
lib/xmlmunger/parser.rb

#initialize(xml, nori_options = {}) ⇒ Parser

Returns a new instance of Parser.



8
9
10
11
12
13
14
15
16
17
# File 'lib/xmlmunger/parser.rb', line 8

def initialize xml, nori_options = {}
  unless xml.is_a?(Hash)
    unless xml.is_a?(String)
      raise ArgumentError.new("Argument xml should be a Hash or String (XML file).")
    end
    @xml = ::Nori.new(NoriConstants.default_options.merge(nori_options)).parse(xml)
  else
    @xml = xml
  end
end