Class: SAXMachine::SAXOxHandler

Inherits:
Ox::Sax
  • Object
show all
Includes:
SAXAbstractHandler
Defined in:
lib/sax-machine/handlers/sax_ox_handler.rb

Constant Summary

Constants included from SAXAbstractHandler

SAXMachine::SAXAbstractHandler::NO_BUFFER

Instance Method Summary collapse

Methods included from SAXAbstractHandler

#_characters, #_end_element, #_error, #_initialize, #_start_element, #_warning

Constructor Details

#initialize(*args) ⇒ SAXOxHandler

Returns a new instance of SAXOxHandler.



8
9
10
11
# File 'lib/sax-machine/handlers/sax_ox_handler.rb', line 8

def initialize(*args)
  _initialize(*args)
  _reset_element
end

Instance Method Details

#attr(name, str) ⇒ Object



21
22
23
# File 'lib/sax-machine/handlers/sax_ox_handler.rb', line 21

def attr(name, str)
  @attrs[name] = str
end

#attrs_doneObject



25
26
27
28
# File 'lib/sax-machine/handlers/sax_ox_handler.rb', line 25

def attrs_done
  _start_element(@element, @attrs)
  _reset_element
end

#error(message, line, column) ⇒ Object



34
35
36
# File 'lib/sax-machine/handlers/sax_ox_handler.rb', line 34

def error(message, line, column)
  _error("#{message} on line #{line} column #{column}")
end

#sax_parse(xml_text) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/sax-machine/handlers/sax_ox_handler.rb', line 13

def sax_parse(xml_text)
  Ox.sax_parse(self, StringIO.new(xml_text),
    symbolize: false,
    convert_special: true,
    skip: :skip_return,
  )
end

#start_element(name) ⇒ Object



30
31
32
# File 'lib/sax-machine/handlers/sax_ox_handler.rb', line 30

def start_element(name)
  @element = name
end