Class: Base::Stack

Inherits:
Object
  • Object
show all
Defined in:
lib/base/stack.rb

Constant Summary collapse

Error =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initializeStack

Returns a new instance of Stack.



5
6
7
# File 'lib/base/stack.rb', line 5

def initialize
  @stack = []
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/base/stack.rb', line 17

def empty?
  @stack.empty?
end

#innerObject



21
22
23
# File 'lib/base/stack.rb', line 21

def inner
  @stack
end

#popObject



13
14
15
# File 'lib/base/stack.rb', line 13

def pop
  @stack.pop or raise Error, "pop requested on empty stack"
end

#push(value) ⇒ Object



9
10
11
# File 'lib/base/stack.rb', line 9

def push(value)
  @stack.push(value)
end