Class Proc
In: lib/facets/more/openobject.rb
lib/facets/core/proc/bind.rb
lib/facets/core/proc/to_h.rb
lib/facets/core/proc/to_method.rb
lib/facets/core/proc/compose.rb
lib/facets/core/proc/op_mul.rb
lib/facets/core/proc/update.rb
Parent: Object

Methods

*   bind   compose   to_h   to_method   to_openobject  

External Aliases

call -> update
  Use a Proc as an observable.

Public Instance methods

Operator for Proc#compose and Integer#times_collect/of.

 a = lambda { |x| x + 4 }
 b = lambda { |y| y / 2 }

 (a * b).call(4)  #=> 6
 (b * a).call(4)  #=> 4

Bind a proc to an object. Returns a Method.

The block‘s to_s method (same as inspect) is used for the temporary method label defined in the Object class.

Returns a new proc that is the functional compostion of two procs, in order.

 a = lambda { |x| x + 4 }
 b = lambda { |y| y / 2 }

 a.compose(b).call(4)  #=> 6
 b.compase(a).call(4)  #=> 4

Build a hash out of a Proc.

  l = lambda { |s|
    s.a = 1
    s.b = 2
    s.c = 3
  }
  l.to_h  #=> {:a=>1, :b=>2, :c=>3}

Translates a Proc into an OpenObject. By droping an OpenObject into the Proc, the resulting assignments incured as the procedure is evaluated produce the OpenObject. This technique is simlar to that of MethodProbe.

  p = lambda { |x|
    x.word = "Hello"
  }
  o = p.to_openobject
  o.word #=> "Hello"

NOTE The Proc must have an arity of one —no more and no less.

[Validate]