Class: Fake::InfiniteQueue
- Inherits:
-
Object
- Object
- Fake::InfiniteQueue
- Defined in:
- lib/fake_service.rb
Overview
Queue which returns last value forever
Instance Method Summary collapse
- #<<(item) ⇒ Object
-
#initialize ⇒ InfiniteQueue
constructor
A new instance of InfiniteQueue.
- #next ⇒ Object
Constructor Details
#initialize ⇒ InfiniteQueue
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 |
#next ⇒ Object
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 |