Class: AntiSamy::Stack

Inherits:
Object
  • Object
show all
Defined in:
lib/antisamy/html/sax_filter.rb

Overview

Quick and Dirty Stack class

Instance Method Summary collapse

Constructor Details

#initializeStack

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

Returns:

  • (Boolean)


20
21
22
# File 'lib/antisamy/html/sax_filter.rb', line 20

def empty?
  @stack.empty?
end

#peekObject



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

Returns:

  • (Boolean)


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

#popObject

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

#sizeObject

size of stack



16
17
18
# File 'lib/antisamy/html/sax_filter.rb', line 16

def size
  @stack.size
end