class SAXMachine::SAXOxHandler

Public Class Methods

new(*args) click to toggle source
# File lib/sax-machine/handlers/sax_ox_handler.rb, line 8
def initialize(*args)
  _initialize(*args)
  _reset_element
end

Public Instance Methods

attr(name, str) click to toggle source
# File lib/sax-machine/handlers/sax_ox_handler.rb, line 24
def attr(name, str)
  @attrs[name] = str
end
attrs_done() click to toggle source
# File lib/sax-machine/handlers/sax_ox_handler.rb, line 28
def attrs_done
  _start_element(@element, @attrs)
  _reset_element
end
cdata(value)
Alias for: text
error(message, line, column) click to toggle source
# File lib/sax-machine/handlers/sax_ox_handler.rb, line 43
def error(message, line, column)
  _error("#{message} on line #{line} column #{column}")
end
sax_parse(xml_input) click to toggle source
# File lib/sax-machine/handlers/sax_ox_handler.rb, line 13
def sax_parse(xml_input)
  # Ox requires input to be streamable
  xml_input = StringIO.new(xml_input) if xml_input.is_a?(String)

  Ox.sax_parse(self, xml_input,
    symbolize: false,
    convert_special: true,
    skip: :skip_return,
  )
end
start_element(name) click to toggle source
# File lib/sax-machine/handlers/sax_ox_handler.rb, line 33
def start_element(name)
  @element = name
end
text(value) click to toggle source
# File lib/sax-machine/handlers/sax_ox_handler.rb, line 37
def text(value)
  _characters(value) if value && !value.empty?
end
Also aliased as: cdata

Private Instance Methods

_reset_element() click to toggle source
# File lib/sax-machine/handlers/sax_ox_handler.rb, line 51
def _reset_element
  @attrs = {}
  @element = ""
end