Class: InThreads::Splitter::Transfer

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/in_threads.rb

Overview

Enumerable using Queue

Instance Method Summary collapse

Constructor Details

#initializeTransfer

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

#finishObject



84
85
86
# File 'lib/in_threads.rb', line 84

def finish
  @queue << nil
end