class Fortnox::API::CircularQueue

Public Class Methods

new(*items) click to toggle source
# File lib/fortnox/api/circular_queue.rb, line 12
def initialize(*items)
  @queue = [*items]
  @@next_index = random_start_index
end

Public Instance Methods

next() click to toggle source
# File lib/fortnox/api/circular_queue.rb, line 20
def next
  value = @queue[@@next_index]
  if @@next_index == size - 1
    @@next_index = 0
  else
    @@next_index += 1
  end
  value
end

Private Instance Methods

random_start_index() click to toggle source
# File lib/fortnox/api/circular_queue.rb, line 32
def random_start_index
  Random.rand(@queue.size)
end