Class: Google::Cloud::Speech::Stream::EnumeratorQueue

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/google/cloud/speech/stream.rb

Instance Method Summary collapse

Constructor Details

#initialize(sentinel) ⇒ EnumeratorQueue

Returns a new instance of EnumeratorQueue.



544
545
546
547
# File 'lib/google/cloud/speech/stream.rb', line 544

def initialize sentinel
  @q = Queue.new
  @sentinel = sentinel
end

Instance Method Details

#each_itemObject



550
551
552
553
554
555
556
557
558
# File 'lib/google/cloud/speech/stream.rb', line 550

def each_item
  return enum_for(:each_item) unless block_given?
  loop do
    r = @q.pop
    break if r.equal? @sentinel
    fail r if r.is_a? Exception
    yield r
  end
end