class ChupaText::Decomposers::OfficeOpenXML::TextListener

Public Class Methods

new(output, target_uri) click to toggle source
# 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

Public Instance Methods

cdata(content) click to toggle source
# File lib/chupa-text/decomposers/office-open-xml.rb, line 106
def cdata(content)
  add_text(content)
end
characters(text) click to toggle source
# File lib/chupa-text/decomposers/office-open-xml.rb, line 102
def characters(text)
  add_text(text)
end
end_element(uri, local_name, qname) click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

add_text(text) click to toggle source
# File lib/chupa-text/decomposers/office-open-xml.rb, line 111
def add_text(text)
  return unless @in_target
  @output << text
end