Module EnumerableArgs
In: lib/facet/enumerable-args.rb

Description

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 'facet/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]

Note

The sort method still needs to be done.

Methods

collect   detect   each_by   each_slice   entries   find   find_all   grep   include?   map   max   member?   min   reject   select   sort   to_a  

Constants

VERSION = '0.9.0'

Public Instance methods

each_by(*args, &yld)

Alias for each_slice

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.

entries(*args)

Alias for to_a

find(*args)

Alias for detect

find_all(*args)

Alias for select

map(*args)

Alias for collect

member?(anObj, *args)

Alias for include?

 problematic for multiple arity on block

def each_with_index(*args)

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

end

[Validate]