Enumerable::Arguments
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
pkg
test
var
.gemspec
.gitignore
.index
.travis.yml
Assembly
Gemfile
HISTORY.md
LICENSE
MANIFEST
README.md
Rakefile

README.md

Enumerable::Arguments

Website / Report Issue / Gem Package / Source Code ( Build Status )

This is a simple reimplementation of the core Enumerable module to allow its methods to take and pass on arbitrary arguments to the underlying #each call. This library uses Enumerator and scans Enumerable to dynamically construct its methods, so it should always be in sync with the current implementation of Ruby's Enumerable module.

Limitations

  • Methods #inject and #zip cannot use pass-on parameters, b/c they already have their own.
  • Methods #find and #detect have a modified interface so they can support pass-on parameters.

Synopsis

   class T
     include Enumerable::Arguments

     def initialize(arr)
       @arr = arr
     end

     def each(n)
       arr.each{ |e| yield(e+n) }
     end
   end

   t = T.new([1,2,3])

   t.map(4)  #=> [5,6,7]

Installation

To install with RubyGems simply open a console and type:

gem install enumargs

Local installation requires Setup.rb (gem install setup), then download the tarball package and type:

tar -xvzf enumargs-2.0.0.tgz
cd enumargs-2.0.0
sudo setup.rb all

Windows users use 'ruby setup.rb all'.

Copyrights

Enumargs is copyrighted open source software.

Copyright (c) 2004 Rubyworks

This program is distributed under the terms of the BSD-2-Clause license.

See LICENSE file for details.