Class: Burlap::Listener
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- Burlap::Listener
- Defined in:
- lib/burlap/listener.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
- #characters(contents) ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize ⇒ Listener
constructor
A new instance of Listener.
- #start_element(name, attrs = []) ⇒ Object
Constructor Details
#initialize ⇒ Listener
Returns a new instance of Listener.
7 8 9 10 |
# File 'lib/burlap/listener.rb', line 7 def initialize @result = nil @open = [] end |
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
5 6 7 |
# File 'lib/burlap/listener.rb', line 5 def result @result end |
Instance Method Details
#characters(contents) ⇒ Object
16 17 18 |
# File 'lib/burlap/listener.rb', line 16 def characters contents @open.last.value += contents if @open.last end |
#end_element(name) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/burlap/listener.rb', line 20 def end_element name last = @open.pop if @open.empty? @result = last.to_ruby else @open.last.children.push last end end |