Sha256: 0a7481d3eb7b5d15df4dec20a1262194b20ab78f783918f315386481f4124264

Contents?: true

Size: 441 Bytes

Versions: 7

Compression:

Stored size: 441 Bytes

Contents

# TITLE:
#   Stackable
#
# DESCRIPTION:
#   Stackable mixin.

# Stackable mixin provides #pop, #push, #pull, etc.
# It depends on #slice, #splice and #insert.

module Stackable

  #

  def pop
    splice(-1)
  end

  #

  def push(x)
    insert(-1,x)
  end

  #

  def pull
    slice(0)
  end

  alias_method :shift, :pull

  #

  def poke(x)
    insert(0,x)
  end

  alias_method :unshift, :poke

  #

  def peek
    splice(-1)
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facets-2.1.2 lib/core/facets/stackable.rb
facets-2.0.3 lib/core/facets/stackable.rb
facets-2.0.4 lib/core/facets/stackable.rb
facets-2.0.5 lib/core/facets/stackable.rb
facets-2.1.0 lib/core/facets/stackable.rb
facets-2.1.1 lib/core/facets/stackable.rb
facets-2.1.3 lib/core/facets/stackable.rb