Class: EnumerableFu::Filter
- Inherits:
-
Object
- Object
- EnumerableFu::Filter
- Includes:
- Enumerable
- Defined in:
- lib/enumerable_fu/filtering.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(&generator) ⇒ Filter
constructor
A new instance of Filter.
Methods included from Enumerable
#collecting, #rejecting, #selecting, #uniqing, #uniqing_by
Constructor Details
#initialize(&generator) ⇒ Filter
Returns a new instance of Filter.
9 10 11 |
# File 'lib/enumerable_fu/filtering.rb', line 9 def initialize(&generator) @generator = generator end |
Instance Method Details
#each ⇒ Object
13 14 15 16 17 |
# File 'lib/enumerable_fu/filtering.rb', line 13 def each return to_enum unless block_given? yielder = proc { |x| yield x } @generator.call(yielder) end |