Class: ChupaText::Decomposers::OpenDocumentText::TextListener

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

Constant Summary collapse

TEXT_URI =
"urn:oasis:names:tc:opendocument:xmlns:text:1.0"

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ TextListener

Returns a new instance of TextListener.



52
53
54
55
# File 'lib/chupa-text/decomposers/opendocument-text.rb', line 52

def initialize(output)
  @output = output
  @in_p = false
end

Instance Method Details

#cdata(content) ⇒ Object



79
80
81
# File 'lib/chupa-text/decomposers/opendocument-text.rb', line 79

def cdata(content)
  add_text(content)
end

#characters(text) ⇒ Object



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

def characters(text)
  add_text(text)
end

#end_element(uri, local_name, qname) ⇒ Object



65
66
67
68
69
70
71
72
73
# File 'lib/chupa-text/decomposers/opendocument-text.rb', line 65

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

  return unless uri == TEXT_URI
  case local_name
  when "p"
    @output << "\n"
  end
end

#start_element(uri, local_name, qname, attributes) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/chupa-text/decomposers/opendocument-text.rb', line 57

def start_element(uri, local_name, qname, attributes)
  return unless uri == TEXT_URI
  case local_name
  when "p"
    @in_p = true
  end
end