Class: Fabric::EnumeratorQueue
- Inherits:
-
Object
- Object
- Fabric::EnumeratorQueue
- Extended by:
- Forwardable
- Defined in:
- lib/fabric/queue.rb,
lib/fabric/enumerator_queue.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(sentinel) ⇒ EnumeratorQueue
constructor
A new instance of EnumeratorQueue.
Constructor Details
#initialize(sentinel) ⇒ EnumeratorQueue
Returns a new instance of EnumeratorQueue.
7 8 9 10 |
# File 'lib/fabric/queue.rb', line 7 def initialize(sentinel) @q = Queue.new @sentinel = sentinel end |
Instance Method Details
#each ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fabric/queue.rb', line 12 def each return enum_for(:each) unless block_given? loop do r = @q.pop break if r.equal?(@sentinel) raise r if r.is_a? Exception yield r end end |