Class: InThreads::Splitter::Transfer
- Inherits:
-
Object
- Object
- InThreads::Splitter::Transfer
- Includes:
- Enumerable
- Defined in:
- lib/in_threads.rb
Overview
Enumerable using Queue
Instance Method Summary collapse
- #<<(args) ⇒ Object
- #each(&block) ⇒ Object
- #finish ⇒ Object
-
#initialize ⇒ Transfer
constructor
A new instance of Transfer.
Constructor Details
#initialize ⇒ Transfer
Returns a new instance of Transfer.
76 77 78 |
# File 'lib/in_threads.rb', line 76 def initialize @queue = Queue.new end |
Instance Method Details
#<<(args) ⇒ Object
80 81 82 |
# File 'lib/in_threads.rb', line 80 def <<(args) @queue << args end |
#each(&block) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/in_threads.rb', line 88 def each(&block) while (args = @queue.pop) block.call(*args) end nil # non reusable end |
#finish ⇒ Object
84 85 86 |
# File 'lib/in_threads.rb', line 84 def finish @queue << nil end |