Class: Fortnox::API::CircularQueue

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/fortnox/api/circular_queue.rb

Instance Method Summary collapse

Constructor Details

#initialize(*items) ⇒ CircularQueue

Returns a new instance of CircularQueue.



8
9
10
11
# File 'lib/fortnox/api/circular_queue.rb', line 8

def initialize *items
  @queue = [ *items ]
  @@next_index = random_start_index
end

Instance Method Details

#nextObject



16
17
18
19
20
21
22
23
24
# File 'lib/fortnox/api/circular_queue.rb', line 16

def next
  value = @queue[ @@next_index ]
  if @@next_index == size - 1
    @@next_index = 0
  else
    @@next_index += 1
  end
  return value
end