Sha256: c896ce29bb9a41409abd97588a5b54fd03a00d10c16985025b4a0128f345bfd0
Contents?: true
Size: 503 Bytes
Versions: 7
Compression:
Stored size: 503 Bytes
Contents
# frozen_string_literal: true 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
7 entries across 7 versions & 1 rubygems