Method: MultiXml.parser=

Defined in:
lib/multi_xml.rb

.parser=(new_parser) ⇒ Object

Set the XML parser utilizing a symbol, string, or class. Supported by default are:

  • :libxml
  • :nokogiri
  • :ox
  • :rexml
  • :oga
[View source]

113
114
115
116
117
118
119
120
121
122
123
# File 'lib/multi_xml.rb', line 113

def parser=(new_parser)
  case new_parser
  when String, Symbol
    require "multi_xml/parsers/#{new_parser.to_s.downcase}"
    @parser = MultiXml::Parsers.const_get(new_parser.to_s.split("_").collect(&:capitalize).join.to_s)
  when Class, Module
    @parser = new_parser
  else
    raise("Did not recognize your parser specification. Please specify either a symbol or a class.")
  end
end