Sha256: 828f3ee4c93985864d30c8bd66660032358b39d853d1f8801fb09097cd7ef910

Contents?: true

Size: 504 Bytes

Versions: 3

Compression:

Stored size: 504 Bytes

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
picolena-0.1.6 rails_plugins/rspec/examples/pure/stack.rb
picolena-0.1.7 rails_plugins/rspec/examples/pure/stack.rb
picolena-0.1.8 rails_plugins/rspec/examples/pure/stack.rb