class Plaintext::ZippedXmlHandler::SaxDocument
Attributes
text[R]
Public Class Methods
new(text_element, text_namespace, max_size = nil)
click to toggle source
# File lib/plaintext/file_handler/zipped_xml_handler.rb, line 12 def initialize(text_element, text_namespace, max_size = nil) @element = text_element @namespace_uri = text_namespace @max_size = max_size @text = ''.dup @is_text = false end
Public Instance Methods
characters(string)
click to toggle source
Any characters between the start and end element expected as a string
# File lib/plaintext/file_handler/zipped_xml_handler.rb, line 37 def characters(string) @text << string if @is_text end
end_element_namespace(name, prefix = nil, uri = nil)
click to toggle source
Given the name of an element once its closing tag is reached
# File lib/plaintext/file_handler/zipped_xml_handler.rb, line 42 def end_element_namespace(name, prefix = nil, uri = nil) if name == @element and uri == @namespace_uri and @is_text @text << ' ' @is_text = false end end
start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = [])
click to toggle source
Handle each element, expecting the name and any attributes
# File lib/plaintext/file_handler/zipped_xml_handler.rb, line 27 def start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = []) if name == @element and uri == @namespace_uri and !text_length_exceeded? @is_text = true end end
text_length_exceeded?()
click to toggle source
# File lib/plaintext/file_handler/zipped_xml_handler.rb, line 21 def text_length_exceeded? @max_size && (@text.length > @max_size) end