Class: DStream::Scan
Instance Method Summary collapse
- #apply(s) ⇒ Object
-
#initialize(init, &block) ⇒ Scan
constructor
A new instance of Scan.
Methods inherited from Abstract
Constructor Details
#initialize(init, &block) ⇒ Scan
Returns a new instance of Scan.
35 36 37 38 |
# File 'lib/d-stream.rb', line 35 def initialize(init, &block) @init = init @block = block end |
Instance Method Details
#apply(s) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/d-stream.rb', line 40 def apply(s) Enumerator.new do |y| acc = @init s.each do |e| acc = @block.call(acc, e) y << acc end end.lazy end |