Class: SaxStream::Internal::HandlerStack
- Inherits:
-
Object
- Object
- SaxStream::Internal::HandlerStack
- Defined in:
- lib/sax_stream/internal/handler_stack.rb
Instance Method Summary collapse
-
#initialize ⇒ HandlerStack
constructor
A new instance of HandlerStack.
- #pop(handler = nil) ⇒ Object
- #push(handler) ⇒ Object
- #root=(value) ⇒ Object
- #top ⇒ Object
Constructor Details
#initialize ⇒ HandlerStack
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
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 |
#top ⇒ Object
12 13 14 |
# File 'lib/sax_stream/internal/handler_stack.rb', line 12 def top @handlers.last end |