Class: ChupaText::Decomposers::OfficeOpenXML::TextListener

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

Instance Method Summary collapse

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



111
112
113
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 111

def cdata(content)
  add_text(content)
end

#characters(text) ⇒ Object



107
108
109
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 107

def characters(text)
  add_text(text)
end

#end_element(uri, local_name, qname) ⇒ Object



97
98
99
100
101
102
103
104
105
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 97

def end_element(uri, local_name, qname)
  @in_target = false

  return unless uri == @target_uri
  case local_name
  when "p", "br"
    @output << "\n"
  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