Class: Proc

Inherits:
Object
  • Object
show all
Defined in:
lib/matilda-function.rb

Defined Under Namespace

Classes: RecursiveStep

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.recursive(&block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/matilda-function.rb', line 2

def self.recursive(&block)
  Proc.new do |args|
    step = RecursiveStep.new
    returned = block.call(step, *args)

    while returned.kind_of?(RecursiveStep)
      returned = block.call(step, *returned.args)
    end

    returned
  end
end

Instance Method Details

#+(func) ⇒ Object



21
22
23
24
25
26
# File 'lib/matilda-function.rb', line 21

def +(func)
  Proc.new do |*args|
    self.call(*args)
    func.call(*args)
  end
end

#<<(func) ⇒ Object



15
16
17
18
19
# File 'lib/matilda-function.rb', line 15

def <<(func)
  Proc.new do |*args|
    func.call(self.call(*args))
  end
end