This is a simple reimplementation of the core Enumerable module to allow the methods to take and pass-on arbitrary arguments to the underlying each call.

Synopsis

  require 'enumerable_args'

  class T
    include EnumerableArgs
    def initialize(arr)
      @arr = arr
    end
    def each(n)
      arr.each{ |e| yield(e+n) }
    end
  end

  t = T.new([1,2,3])
  t.collect(4)
  #=> [5,6,7]

Author(s)

  Thomas Sawyer
Methods
Constants
VERSION = '0.9.0'
Public Instance methods
collect(*args) {|| ...} [ source ]
This method is also aliased as map
detect(*args) {|| ...} [ source ]
This method is also aliased as find
each_by(*args, &yld)

Alias for each_slice

each_slice(*args, &yld) [ source ]

An additional method not part of standard Enumerable. The regular version of this method can be found in Facets, but it is a bit more advanced then this one. At some point they need to be put into sync.

This method is also aliased as each_by
entries(*args)

Alias for to_a

find(*args)

Alias for detect

find_all(*args)

Alias for select

grep(pattern, *args) {|n| ...} [ source ]
include?(anObj, *args) [ source ]
This method is also aliased as member?
map(*args)

Alias for collect

max(*args) [ source ]
member?(anObj, *args)

Alias for include?

min(*args) [ source ]
reject(*args) {|n| ...} [ source ]
select(*args) {|| ...} [ source ]
This method is also aliased as find_all
sort(*args) [ source ]
to_a(*args) [ source ]
 problematic for multiple arity on block

def each_with_index(*args)

  i=0
  each(*args){ |n,i| yield(n); i+=1 }
  self

end

This method is also aliased as entries