Module: Nori::Parser

Defined in:
lib/nori/parser.rb,
lib/nori/parser/rexml.rb,
lib/nori/parser/nokogiri.rb

Overview

Nori::Parser

Manages the parser classes. Currently supports:

  • REXML

  • Nokogiri

Defined Under Namespace

Modules: Nokogiri, REXML

Constant Summary collapse

DEFAULT =

The default parser.

:rexml
PARSERS =

List of available parsers.

{ :rexml => "REXML", :nokogiri => "Nokogiri" }

Class Method Summary collapse

Class Method Details

.parse(xml, parser = nil) ⇒ Object

Returns the parsed xml using the parser to use. Raises an ArgumentError unless the optional or default parser exists.



30
31
32
# File 'lib/nori/parser.rb', line 30

def self.parse(xml, parser = nil)
  load_parser(parser).parse xml
end

.useObject

Returns the parser to use. Defaults to Nori::Parser::REXML.



18
19
20
# File 'lib/nori/parser.rb', line 18

def self.use
  @use ||= DEFAULT
end

.use=(parser) ⇒ Object

Sets the parser to use. Raises an ArgumentError unless the parser exists.



23
24
25
26
# File 'lib/nori/parser.rb', line 23

def self.use=(parser)
  validate_parser! parser
  @use = parser
end