class DataStructureType::Stack
Public Class Methods
new()
click to toggle source
# File lib/data_structure_type/stack.rb, line 3 def initialize @stack = [] end
Public Instance Methods
add(data)
click to toggle source
# File lib/data_structure_type/stack.rb, line 7 def add(data) data.present? ? @stack.push(data) : @stack end
empty?()
click to toggle source
# File lib/data_structure_type/stack.rb, line 19 def empty? @stack.empty? end
peek()
click to toggle source
# File lib/data_structure_type/stack.rb, line 11 def peek @stack.last unless @stack.empty? end
pop()
click to toggle source
# File lib/data_structure_type/stack.rb, line 15 def pop @stack.pop unless @stack.empty? end