Class

Method

Extends:

Proc objects are blocks of code that have been bound to a set of local variables. Once bound, the code may be called in different contexts and still access those variables.

def gen_times(factor)
  return Proc.new {|n| n*factor }
end

times3 = gen_times(3)
times5 = gen_times(5)

times3.call(12)               #=> 36
times5.call(5)                #=> 25
times3.call(times5.call(4))   #=> 60
Public Methods
== Two method objects are equal if that are bound to the same object and contain the same body.
[] Invokes the meth with the specified arguments, returning the method’s return value.
arity Returns an indication of the number of arguments accepted by a method. Returns a nonnegative integer for methods that take a fixed number of arguments. For Ruby methods that take a variable number of arguments, returns -n-1, where n is the number of required arguments. For methods written in C, returns -1 if the call takes a variable number of arguments.
call Invokes the meth with the specified arguments, returning the method’s return value.
clone MISSING: documentation
inspect Show the name of the underlying method.
to_proc Returns a Proc object corresponding to this method.
to_s Show the name of the underlying method.
unbind Dissociates meth from it’s current receiver. The resulting UnboundMethod can subsequently be bound to a new object of the same class (see UnboundMethod).
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.