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.



78
79
80
81
82
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 78

def initialize(output, target_uri)
  @output = output
  @target_uri = target_uri
  @in_target = false
end

Instance Method Details

#cdata(content) ⇒ Object



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

def cdata(content)
  add_text(content)
end

#characters(text) ⇒ Object



102
103
104
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 102

def characters(text)
  add_text(text)
end

#end_element(uri, local_name, qname) ⇒ Object



92
93
94
95
96
97
98
99
100
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 92

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



84
85
86
87
88
89
90
# File 'lib/chupa-text/decomposers/office-open-xml.rb', line 84

def start_element(uri, local_name, qname, attributes)
  return unless uri == @target_uri
  case local_name
  when "t"
    @in_target = true
  end
end