Class: Fake::InfiniteQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_service.rb

Overview

Queue which returns last value forever

Instance Method Summary collapse

Constructor Details

#initializeInfiniteQueue

Returns a new instance of InfiniteQueue.



20
21
22
23
# File 'lib/fake_service.rb', line 20

def initialize
  @current_item_index = 0
  @items = []
end

Instance Method Details

#<<(item) ⇒ Object



25
26
27
# File 'lib/fake_service.rb', line 25

def <<(item)
  @items << item
end

#nextObject



29
30
31
32
33
# File 'lib/fake_service.rb', line 29

def next
  item = @items[@current_item_index]
  @current_item_index += 1 if @current_item_index < (@items.count - 1)
  item
end