Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A pattern for simple block-free ruby enumeration
Ruby
Branch: master
Failed to load latest commit information.
lib array pmethods
test
.document
.gitignore
LICENSE jeweler
README.textile
Rakefile rename github repo
VERSION Version bump to 1.1.4
enumerable-proxy.gemspec gemspec

README.textile

Enumerable Proxy

Background

See here and here

Installation

sudo gem install enumerable-proxy

Usage


require 'enumerable_proxy'

[1, 2, 3].proxy(:map) == 2 #=> [false, true, false]

[1, 2, 3].p(:map).to_s #=> ['1', '2', '3']

[1, 2, 3].pmap * 10 #=> [10, 20, 30]

#peach, pmap, pselect, preject, pall?, pany?, pdetect are all added to Array.

To get even more succinct, require enumerable_proxy/array_extensions and
it’ll alias_method_chain Array#map, each, etc so if they are called with no block,
they will return a proxy for their method.


require 'enumerable_proxy/array_extensions'

[1, 2, 3].map.to_s #=> ['1', '2', '3']
[1, 2, 3].map + 2 #=> [3, 4, 5]

(0..10).to_a.select < 5 #=> [0, 1, 2, 3, 4]
Something went wrong with that request. Please try again.