Class: InThreads::Splitter
- Inherits:
-
Object
- Object
- InThreads::Splitter
- Defined in:
- lib/in_threads.rb
Overview
Yield objects of one enum in multiple places
Defined Under Namespace
Classes: Transfer
Instance Attribute Summary collapse
-
#enums ⇒ Object
readonly
Enums receiving items.
Instance Method Summary collapse
-
#initialize(enumerable, enum_count) ⇒ Splitter
constructor
A new instance of Splitter.
Constructor Details
#initialize(enumerable, enum_count) ⇒ Splitter
Returns a new instance of Splitter.
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/in_threads.rb', line 99 def initialize(enumerable, enum_count) @enums = Array.new(enum_count){ Transfer.new } @filler = Thread.new do enumerable.each do |*args| @enums.each do |enum| enum << args end end @enums.each(&:finish) end end |
Instance Attribute Details
#enums ⇒ Object (readonly)
Enums receiving items
97 98 99 |
# File 'lib/in_threads.rb', line 97 def enums @enums end |