Stackable

Stackable

Stackable mixin provides #, #, #, etc. It depends on #, # and #.

Public Instance Methods

peek() click to toggle source

Peek at the top of the stack.

  a = [1, 2, 3]
  a.peek          #=> 3
  a               #=> [1, 2, 3]
    # File lib/core/facets/stackable.rb, line 81
81:   def peek
82:     slice(1)
83:   end
poke(x) click to toggle source

Poke item onto the stack.

  a = [2, 3]
  a.poke(1)       #=> [1, 2, 3]

  TODO: Better name (besides unshift)?
    # File lib/core/facets/stackable.rb, line 69
69:   def poke(x)
70:     insert(0,x)
71:   end
Also aliased as: unshift
pop() click to toggle source

Pop item off stack.

  a = [1, 2, 3]
  a.pop           #=> 3
  a               #=> [1, 2]
    # File lib/core/facets/stackable.rb, line 37
37:   def pop
38:     splice(1)
39:   end
pull() click to toggle source

Pull item off the stack.

  a = [1, 2, 3]
  a.pull          #=> 1
  a               #=> [2, 3]
    # File lib/core/facets/stackable.rb, line 56
56:   def pull
57:     slice(0)
58:   end
Also aliased as: shift
push(x) click to toggle source

Push item onto the stack.

  a = [1, 2]
  a.push(3)       #=> [1, 2, 3]
    # File lib/core/facets/stackable.rb, line 46
46:   def push(x)
47:     insert(1,x)
48:   end
shift() click to toggle source
Alias for: pull
unshift(x) click to toggle source
Alias for: poke

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.