class Sheaf::Stack

Constants

Root
SWYM

Attributes

parent[R]
stackable[R]

Public Class Methods

[](*args) click to toggle source
# File lib/sheaf/stack.rb, line 36
def [](*args)
  return new if args.empty?

  args[1..-1].inject(new(args[0])) do |stack, stackable|
    stack.add(stackable)
  end
end
build(&block) click to toggle source
# File lib/sheaf/stack.rb, line 44
def build(&block)
  DSLProxy.apply(new, &block)
end
new(*args, &block) click to toggle source
Calls superclass method
# File lib/sheaf/stack.rb, line 32
def new(*args, &block)
  args.empty? ? Root : super
end
new(stackable = Root, parent = Root) click to toggle source
# File lib/sheaf/stack.rb, line 49
def initialize(stackable = Root, parent = Root)
  @stackable = stackable
  @parent = parent
end

Public Instance Methods

==(other) click to toggle source
# File lib/sheaf/stack.rb, line 83
def ==(other)
  stackable == other.stackable && parent == other.parent
end
add(stackable) click to toggle source
# File lib/sheaf/stack.rb, line 79
def add(stackable)
  self.class.new(stackable, self)
end
call(*args, &block) click to toggle source
# File lib/sheaf/stack.rb, line 54
def call(*args, &block)
  parent.(*args) do |*args|
    stackable.(*args, &block || SWYM)
  end
end
each() { |stackable| ... } click to toggle source
# File lib/sheaf/stack.rb, line 60
def each(&block)
  parent.each(&block)
  stackable.kind_of?(self.class) ? stackable.each(&block) : yield(stackable)
end
fmap(&block) click to toggle source
# File lib/sheaf/stack.rb, line 65
def fmap(&block)
  self.class[*map(&block)]
end
inspect()
Alias for: to_s
to_a() click to toggle source
# File lib/sheaf/stack.rb, line 69
def to_a
  map { |stackable| stackable }
end
to_s() click to toggle source
# File lib/sheaf/stack.rb, line 73
def to_s
  "#<#{self.class.name}: #{to_a}>"
end
Also aliased as: inspect