Class: Enumerating::ThreadStarter
- Inherits:
-
Object
- Object
- Enumerating::ThreadStarter
- Includes:
- Enumerable
- Defined in:
- lib/enumerating/threading.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(source, block) ⇒ ThreadStarter
constructor
A new instance of ThreadStarter.
Methods included from Enumerable
#[], #collecting, #dropping, #dropping_while, #prefetching, #rejecting, #selecting, #taking, #taking_while, #threading, #uniqing, #uniqing_by
Constructor Details
#initialize(source, block) ⇒ ThreadStarter
Returns a new instance of ThreadStarter.
9 10 11 12 |
# File 'lib/enumerating/threading.rb', line 9 def initialize(source, block) @source = source @block = block end |
Instance Method Details
#each ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/enumerating/threading.rb', line 14 def each @source.each do |source_item| thread = Thread.new do @block.call(source_item) end yield thread end end |