Class: Opener::KafParser::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/opener/kaf_parser/parser.rb

Overview

The Parser class acts as a slightly more user friendly interface around the Nokogiri SAX based parser.

Instance Method Summary collapse

Instance Method Details

#parse(input) ⇒ Opener::KafParser::AST::Document

Parses the input KAF/XML and returns an instance of AST::Document.

Parameters:

  • input (String)

    The XML/KAF to parse.

Returns:



15
16
17
18
19
20
21
22
# File 'lib/opener/kaf_parser/parser.rb', line 15

def parse(input)
  sax_parser      = SaxParser.new
  nokogiri_parser = Nokogiri::XML::SAX::Parser.new(sax_parser)

  nokogiri_parser.parse(input)

  return sax_parser.document
end