Sha256: adaf80190debedafd295d06f7383fe9755a670781b37119fa22f78e3687ada1e

Contents?: true

Size: 460 Bytes

Versions: 1

Compression:

Stored size: 460 Bytes

Contents

require 'stack_contract'

class Stack

  contract StackContract

  class NoPopForEmptyStack < RuntimeError
  end

  def initialize
    @objects = []
  end

  def initialize_copy(orig)
    @objects = orig.objects
  end

  def objects
    @objects.dup
  end

  def size
    @objects.size
  end

  def empty?
    size == 0
  end

  def top
    @objects.last
  end

  def pop
    @objects.pop
  end

  def push(object)
    @objects.push(object)
    nil
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
armin-joellenbeck-rdbc-0.0.7 examples/stack.rb