Sha256: b6c276a79ef90881996a50ccad23b322d59fc5e8c0974487e4f031d7d1ae84ad
Contents?: true
Size: 316 Bytes
Versions: 6
Compression:
Stored size: 316 Bytes
Contents
class RingBuffer < Array attr_reader :max_size def initialize(max_size, enum = nil) @max_size = max_size enum.each { |e| self << e } if enum end def <<(el) if self.size < @max_size || @max_size.nil? super else self.shift self.push(el) end end alias :push :<< end
Version data entries
6 entries across 6 versions & 2 rubygems