class Method
Public Instance Methods
apply(*args)
click to toggle source
Curries this Method
and partially applies parameters. If a sufficient number of arguments are supplied, it passes the supplied arguments to the original proc and returns the result. Otherwise, returns another curried proc that takes the rest of arguments.
# File lib/mug/apply.rb, line 41 def apply(*args) curry.call(*args) end
curry(n=nil)
click to toggle source
Returns a curried proc. If the optional arity argument is given, it determines the number of arguments. A curried proc receives some arguments. If a sufficient number of arguments are supplied, it passes the supplied arguments to the original proc and returns the result. Otherwise, returns another curried proc that takes the rest of arguments.
# File lib/mug/apply.rb, line 25 def curry(n=nil) if n to_proc.curry n else to_proc.curry end end
to_iter(*args)
click to toggle source
Creates a new Iterator
for this method, initially invoked on this method's receiver.
# File lib/mug/iterator/method.rb, line 9 def to_iter *args Iterator.new(receiver) do |o| o.send(name, *args) end end