Class: Treat::Workers::Formatters::Readers::ODT::ODTXmlHandler

Inherits:
Object
  • Object
show all
Includes:
REXML::StreamListener
Defined in:
lib/treat/workers/formatters/readers/odt.rb

Overview

Xml listener for the parsing of the ODT file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeODTXmlHandler

Returns a new instance of ODTXmlHandler.



47
48
49
50
# File 'lib/treat/workers/formatters/readers/odt.rb', line 47

def initialize
  @plain_text = ""
  @last_name = ""
end

Instance Attribute Details

#plain_textObject (readonly)

Returns the value of attribute plain_text.



46
47
48
# File 'lib/treat/workers/formatters/readers/odt.rb', line 46

def plain_text
  @plain_text
end

Instance Method Details

#tag_start(name, attrs) ⇒ Object



51
52
53
# File 'lib/treat/workers/formatters/readers/odt.rb', line 51

def tag_start(name, attrs)
  @last_name = name
end

#text(s) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/treat/workers/formatters/readers/odt.rb', line 54

def text(s)
  if @last_name.index('text')
    s = s.strip
    if s.length > 0
      @plain_text << s
      @plain_text << "\n\n"
    end
  end
end