Sha256: 99af739ecddd03d572242d6216307ab262facdc1aea11697f49b29094cdd4ef0

Contents?: true

Size: 559 Bytes

Versions: 16

Compression:

Stored size: 559 Bytes

Contents

# Copied without code changes from RSpec.

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

Version data entries

16 entries across 16 versions & 4 rubygems

Version Path
jordi-xml_struct-0.1.3 test/vendor/test-spec/examples/stack.rb
jordi-xml_struct-0.2.0 test/vendor/test-spec/examples/stack.rb
jordi-xml_struct-0.2.1 test/vendor/test-spec/examples/stack.rb
relevance-test-spec-0.4.0.5 examples/stack.rb
relevance-test-spec-0.4.1.1 examples/stack.rb
relevance-test-spec-0.4.1.2 examples/stack.rb
relevance-test-spec-0.4.1 examples/stack.rb
mofo-0.1.2 vendor/testspec-0.3.0/examples/stack.rb
mofo-0.1.1 vendor/testspec-0.2.0/examples/stack.rb
mofo-0.2.2 vendor/testspec-0.3.0/examples/stack.rb
mofo-0.2.1 vendor/testspec-0.3.0/examples/stack.rb
mofo-0.2 vendor/testspec-0.3.0/examples/stack.rb
test-spec-0.10.0 examples/stack.rb
test-spec-0.3.0 examples/stack.rb
test-spec-0.4.0 examples/stack.rb
test-spec-0.9.0 examples/stack.rb