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.
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/in_threads.rb', line 111 def initialize(enumerable, enum_count) @enums = Array.new(enum_count){ Transfer.new } @filler = Thread.new do enumerable.each do |o| @enums.each do |enum| enum << o end end @enums.each(&:finish) end end |
Instance Attribute Details
#enums ⇒ Object (readonly)
Enums receiving items
109 110 111 |
# File 'lib/in_threads.rb', line 109 def enums @enums end |