Class: ChupaText::Decomposers::OfficeOpenXML::TextListener
- Inherits:
-
SAXListener
- Object
- SAXListener
- ChupaText::Decomposers::OfficeOpenXML::TextListener
- Defined in:
- lib/chupa-text/decomposers/office-open-xml.rb
Instance Method Summary collapse
- #cdata(content) ⇒ Object
- #characters(text) ⇒ Object
- #end_element(uri, local_name, qname) ⇒ Object
-
#initialize(output, target_uri) ⇒ TextListener
constructor
A new instance of TextListener.
- #start_element(uri, local_name, qname, attributes) ⇒ Object
Constructor Details
#initialize(output, target_uri) ⇒ TextListener
Returns a new instance of TextListener.
83 84 85 86 87 |
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 83 def initialize(output, target_uri) @output = output @target_uri = target_uri @in_target = false end |
Instance Method Details
#cdata(content) ⇒ Object
112 113 114 |
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 112 def cdata(content) add_text(content) end |
#characters(text) ⇒ Object
108 109 110 |
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 108 def characters(text) add_text(text) end |
#end_element(uri, local_name, qname) ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 97 def end_element(uri, local_name, qname) if uri == @target_uri case local_name when "p", "br" @output << "\n" when "t" @in_target = false end end end |
#start_element(uri, local_name, qname, attributes) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 89 def start_element(uri, local_name, qname, attributes) return unless uri == @target_uri case local_name when "t" @in_target = true end end |