Class: Burlap::Listener

Inherits:
Nokogiri::XML::SAX::Document
  • Object
show all
Defined in:
lib/burlap/listener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeListener

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

#resultObject

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

#start_element(name, attrs = []) ⇒ Object



12
13
14
# File 'lib/burlap/listener.rb', line 12

def start_element name, attrs=[]
  @open.push BaseTag.new(:name => name)
end