summaryrefslogtreecommitdiffstats
path: root/vendor/gems/rspec/examples/stack.rb
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-02-13 20:29:00 +1100
committerJames Turnbull <james@lovedthanlost.net>2008-02-13 20:29:00 +1100
commitd3959c497f4c61995f664d88aa3386b54c4baf8d (patch)
tree1a83a85c0c6d626781cad5632db146aeae49d0c9 /vendor/gems/rspec/examples/stack.rb
parentc3ead0331adba5f60ea7d508775a89de68e26caa (diff)
parentbcb9b564281003e22d72752d84fa9dc9c8c7107b (diff)
downloadpuppet-d3959c497f4c61995f664d88aa3386b54c4baf8d.tar.gz
puppet-d3959c497f4c61995f664d88aa3386b54c4baf8d.tar.xz
puppet-d3959c497f4c61995f664d88aa3386b54c4baf8d.zip
Merge branch '0.24.x' of git://reductivelabs.com/puppet into 0.24.x
Diffstat (limited to 'vendor/gems/rspec/examples/stack.rb')
-rw-r--r--vendor/gems/rspec/examples/stack.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/gems/rspec/examples/stack.rb b/vendor/gems/rspec/examples/stack.rb
new file mode 100644
index 000000000..407173f7b
--- /dev/null
+++ b/vendor/gems/rspec/examples/stack.rb
@@ -0,0 +1,36 @@
+class StackUnderflowError < RuntimeError
+end
+
+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