Class: Stack
- Inherits:
-
Object
- Object
- Stack
- Defined in:
- lib/honey_mushroom/stack.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
Returns the value of attribute stack.
Instance Method Summary collapse
-
#initialize ⇒ Stack
constructor
A new instance of Stack.
- #peek ⇒ Object
- #pop ⇒ Object
- #push(value) ⇒ Object
Constructor Details
#initialize ⇒ Stack
Returns a new instance of Stack.
3 4 5 |
# File 'lib/honey_mushroom/stack.rb', line 3 def initialize @stack = [] end |
Instance Attribute Details
#stack ⇒ Object
Returns the value of attribute stack.
2 3 4 |
# File 'lib/honey_mushroom/stack.rb', line 2 def stack @stack end |
Instance Method Details
#peek ⇒ Object
16 17 18 |
# File 'lib/honey_mushroom/stack.rb', line 16 def peek stack[-1] end |
#pop ⇒ Object
12 13 14 |
# File 'lib/honey_mushroom/stack.rb', line 12 def pop stack.pop end |
#push(value) ⇒ Object
7 8 9 10 |
# File 'lib/honey_mushroom/stack.rb', line 7 def push(value) stack.push(value) return value end |