Class: Pluggaloid::Stream::Merge
- Inherits:
-
Object
- Object
- Pluggaloid::Stream::Merge
- Includes:
- Enumerable
- Defined in:
- lib/pluggaloid/stream.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(*sources) ⇒ Merge
constructor
A new instance of Merge.
Constructor Details
#initialize(*sources) ⇒ Merge
Returns a new instance of Merge.
74 75 76 |
# File 'lib/pluggaloid/stream.rb', line 74 def initialize(*sources) @sources = sources end |
Instance Method Details
#each(&block) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/pluggaloid/stream.rb', line 78 def each(&block) fiber = Fiber.new do loop do block.call(Fiber.yield) end end fiber.resume @sources.each do |source| source.each(&fiber.method(:resume)) end self end |