Class: SaxStream::Internal::HandlerStack

Inherits:
Object
  • Object
show all
Defined in:
lib/sax_stream/internal/handler_stack.rb

Instance Method Summary collapse

Constructor Details

#initializeHandlerStack

Returns a new instance of HandlerStack.



4
5
6
# File 'lib/sax_stream/internal/handler_stack.rb', line 4

def initialize()
  @handlers = []
end

Instance Method Details

#pop(handler = nil) ⇒ Object

Raises:



20
21
22
23
24
# File 'lib/sax_stream/internal/handler_stack.rb', line 20

def pop(handler = nil)
  raise ProgramError, "can't pop the last handler" if @handlers.length <= 1
  raise ProgramError, "popping handler that isn't the top" if handler && handler != @handlers.last
  @handlers.pop
end

#push(handler) ⇒ Object



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

def push(handler)
  @handlers.push(handler)
end

#root=(value) ⇒ Object



8
9
10
# File 'lib/sax_stream/internal/handler_stack.rb', line 8

def root=(value)
  @handlers = [value]
end

#topObject



12
13
14
# File 'lib/sax_stream/internal/handler_stack.rb', line 12

def top
  @handlers.last
end