Class: SaxStream::Internal::SaxHandler

Inherits:
Nokogiri::XML::SAX::Document
  • Object
show all
Defined in:
lib/sax_stream/internal/sax_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(collector, mappers, handler_stack = HandlerStack.new) ⇒ SaxHandler

Returns a new instance of SaxHandler.



8
9
10
11
12
13
14
# File 'lib/sax_stream/internal/sax_handler.rb', line 8

def initialize(collector, mappers, handler_stack = HandlerStack.new)
  @handler_stack = handler_stack
  mapper_handlers = mappers.map do |mapper|
    MapperHandler.new(mapper, collector, @handler_stack)
  end
  @handler_stack.root = CombinedHandler.new(@handler_stack, mapper_handlers)
end

Instance Method Details

#cdata_block(*params) ⇒ Object



28
29
30
# File 'lib/sax_stream/internal/sax_handler.rb', line 28

def cdata_block(*params)
  @handler_stack.top.cdata_block(*params)
end

#characters(*params) ⇒ Object



24
25
26
# File 'lib/sax_stream/internal/sax_handler.rb', line 24

def characters(*params)
  @handler_stack.top.characters(*params)
end

#end_element(*params) ⇒ Object



20
21
22
# File 'lib/sax_stream/internal/sax_handler.rb', line 20

def end_element(*params)
  @handler_stack.top.end_element(*params)
end

#error(string) ⇒ Object

Raises:



32
33
34
# File 'lib/sax_stream/internal/sax_handler.rb', line 32

def error(string)
  raise ParsingError.new(string)
end

#start_element(*params) ⇒ Object



16
17
18
# File 'lib/sax_stream/internal/sax_handler.rb', line 16

def start_element(*params)
  @handler_stack.top.start_element(*params)
end