From: Eric Hodel Date: 2012-02-08T15:38:06+09:00 Subject: [ruby-core:42433] [ruby-trunk - Feature #707] Documentation for Enumerator chaining Issue #707 has been updated by Eric Hodel. Priority changed from Low to Normal I will work on it, thank you. ---------------------------------------- Feature #707: Documentation for Enumerator chaining https://bugs.ruby-lang.org/issues/707 Author: Brian Candler Status: Assigned Priority: Normal Assignee: Eric Hodel Category: DOC Target version: 2.0.0 =begin Enumerators now support a horizontal filter/chaining pattern: generator.filter1 { ... }.filter2 { ... }.filter3 { ... }.consumer The overall pattern for a filter is: Enumerator.new do |y| source.each do |input| # filter INPUT ... y << output # filter OUTPUT end end This is extremely powerful. However it is not obvious to the newcomer that this is even possible. (Confusion may arise where people know Ruby 1.8's Enumerator, which cannot do this) So I would just like to see this pattern documented with an example, e.g. under ri Enumerator.new I have attached a possible example. Note that I have written my Fib generator in a style familiar from ruby-1.8, to emphasise that the Enumerator filter doesn't require a specially-written generator. =end -- http://bugs.ruby-lang.org/