Class: AntiSamy::Stack
- Inherits:
-
Object
- Object
- AntiSamy::Stack
- Defined in:
- lib/antisamy/html/sax_filter.rb
Overview
Quick and Dirty Stack class
Instance Method Summary collapse
-
#empty? ⇒ Boolean
is the stack empty.
-
#initialize ⇒ Stack
constructor
A new instance of Stack.
- #peek ⇒ Object
-
#peek?(v) ⇒ Boolean
peek to see what next element is.
-
#pop ⇒ Object
pop an element off the stack.
-
#push(v) ⇒ Object
push an emement ont he stack.
-
#size ⇒ Object
size of stack.
Constructor Details
#initialize ⇒ Stack
Returns a new instance of Stack.
4 5 6 |
# File 'lib/antisamy/html/sax_filter.rb', line 4 def initialize @stack = [] end |
Instance Method Details
#empty? ⇒ Boolean
is the stack empty
20 21 22 |
# File 'lib/antisamy/html/sax_filter.rb', line 20 def empty? @stack.empty? end |
#peek ⇒ Object
29 30 31 |
# File 'lib/antisamy/html/sax_filter.rb', line 29 def peek @stack.last end |
#peek?(v) ⇒ Boolean
peek to see what next element is
24 25 26 27 |
# File 'lib/antisamy/html/sax_filter.rb', line 24 def peek?(v) return false if @stack.empty? return @stack.last.eql?(v) end |
#pop ⇒ Object
pop an element off the stack
12 13 14 |
# File 'lib/antisamy/html/sax_filter.rb', line 12 def pop @stack.pop end |
#push(v) ⇒ Object
push an emement ont he stack
8 9 10 |
# File 'lib/antisamy/html/sax_filter.rb', line 8 def push(v) @stack.push v end |
#size ⇒ Object
size of stack
16 17 18 |
# File 'lib/antisamy/html/sax_filter.rb', line 16 def size @stack.size end |