Class: ChupaText::Decomposers::XML::Listener

Inherits:
SAXListener
  • Object
show all
Defined in:
lib/chupa-text/decomposers/xml.rb

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Listener

Returns a new instance of Listener.



58
59
60
61
# File 'lib/chupa-text/decomposers/xml.rb', line 58

def initialize(output)
  @output = output
  @level = 0
end

Instance Method Details

#cdata(content) ⇒ Object



75
76
77
# File 'lib/chupa-text/decomposers/xml.rb', line 75

def cdata(content)
  @output << content if @level > 0
end

#characters(text) ⇒ Object



71
72
73
# File 'lib/chupa-text/decomposers/xml.rb', line 71

def characters(text)
  @output << text if @level > 0
end

#end_element(*args) ⇒ Object



67
68
69
# File 'lib/chupa-text/decomposers/xml.rb', line 67

def end_element(*args)
  @level -= 1
end

#start_element(*args) ⇒ Object



63
64
65
# File 'lib/chupa-text/decomposers/xml.rb', line 63

def start_element(*args)
  @level += 1
end