Class: Presenter::Xml::Parser
- Inherits:
-
Object
- Object
- Presenter::Xml::Parser
- Defined in:
- lib/presenter/xml/parser.rb
Instance Method Summary collapse
-
#initialize(excludes: [], includes: [], bases: [], preferred_keys: {}, list_nodes: [], rootless_list_nodes: {}) ⇒ Parser
constructor
A new instance of Parser.
- #parse(xml) ⇒ Object
- #sax_parser ⇒ Object
Constructor Details
#initialize(excludes: [], includes: [], bases: [], preferred_keys: {}, list_nodes: [], rootless_list_nodes: {}) ⇒ Parser
Returns a new instance of Parser.
4 5 6 7 8 9 10 11 |
# File 'lib/presenter/xml/parser.rb', line 4 def initialize(excludes: [], includes: [], bases: [], preferred_keys: {}, list_nodes: [], rootless_list_nodes: {}) @excludes = excludes @includes = includes @bases = bases @preferred_keys = preferred_keys @list_nodes = list_nodes @rootless_list_nodes = rootless_list_nodes end |
Instance Method Details
#parse(xml) ⇒ Object
13 14 15 16 |
# File 'lib/presenter/xml/parser.rb', line 13 def parse(xml) sax_parser.parse xml last_output end |
#sax_parser ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/presenter/xml/parser.rb', line 18 def sax_parser @assessment_document ||= AssessmentDocument.new excludes: @excludes, includes: @includes, bases: @bases, preferred_keys: @preferred_keys, list_nodes: @list_nodes, rootless_list_nodes: @rootless_list_nodes @sax_parser ||= Nokogiri::XML::SAX::Parser.new(@assessment_document) { |config| config.huge.strict } end |