Sha256: e3dbeb47bc48c897ee4ec66bff625c43ca24053421d61f9b2439cc946a30fbd8
Contents?: true
Size: 472 Bytes
Versions: 37
Compression:
Stored size: 472 Bytes
Contents
require "forwardable" module Sidekiq class RingBuffer include Enumerable extend Forwardable def_delegators :@buf, :[], :each, :size def initialize(size, default = 0) @size = size @buf = Array.new(size, default) @index = 0 end def <<(element) @buf[@index % @size] = element @index += 1 element end def buffer @buf end def reset(default = 0) @buf.fill(default) end end end
Version data entries
37 entries across 37 versions & 1 rubygems