Class: Saxerator::Parser::Nokogiri::Document
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- Saxerator::Parser::Nokogiri::Document
- Defined in:
- lib/saxerator/parser/nokogiri.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
Returns the value of attribute stack.
Instance Method Summary collapse
- #characters(string) ⇒ Object (also: #cdata_block)
- #end_element(name) ⇒ Object
-
#initialize(config, tag, block) ⇒ Document
constructor
A new instance of Document.
- #start_element(name, attrs = []) ⇒ Object
Constructor Details
#initialize(config, tag, block) ⇒ Document
Returns a new instance of Document.
27 28 29 30 31 32 |
# File 'lib/saxerator/parser/nokogiri.rb', line 27 def initialize(config, tag, block) @config = config @tag = tag @stack = [] @block = block end |
Instance Attribute Details
#stack ⇒ Object
Returns the value of attribute stack.
25 26 27 |
# File 'lib/saxerator/parser/nokogiri.rb', line 25 def stack @stack end |
Instance Method Details
#characters(string) ⇒ Object Also known as: cdata_block
49 50 51 |
# File 'lib/saxerator/parser/nokogiri.rb', line 49 def characters(string) stack.last.add_node(string) unless string.strip.length == 0 || stack.empty? end |
#end_element(name) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/saxerator/parser/nokogiri.rb', line 40 def end_element(name) if stack.size > 1 last = stack.pop stack.last.add_node last elsif stack.size == 1 @block.yield(stack.pop.to_hash) end end |