rails_plugins/rspec/examples/pure/stack.rb in picolena-0.1.5 vs rails_plugins/rspec/examples/pure/stack.rb in picolena-0.1.6
- old
+ new
@@ -3,34 +3,34 @@
class StackOverflowError < RuntimeError
end
class Stack
-
+
def initialize
@items = []
end
-
+
def push object
raise StackOverflowError if @items.length == 10
@items.push object
end
-
+
def pop
raise StackUnderflowError if @items.empty?
@items.delete @items.last
end
-
+
def peek
raise StackUnderflowError if @items.empty?
@items.last
end
-
+
def empty?
@items.empty?
end
def full?
@items.length == 10
end
-
+
end