Sha256: 30744f97bbb751f45cdc0acd5a00ba33de2d52abc206243bbc22e3dd56008bd7
Contents?: true
Size: 501 Bytes
Versions: 3
Compression:
Stored size: 501 Bytes
Contents
module Fossilize class RingBuffer < Array alias_method :array_push, :push alias_method :array_element, :[] def initialize(size) @ring_size = size super(size) end def push(element) if length == @ring_size shift # loose element end array_push element end # Access elements in the RingBuffer # # offset will be typically negative! # def [](offset = 0) return self.array_element(- 1 + offset) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fossilize-1.1.1 | lib/fossilize/ring_buffer.rb |
fossilize-1.1.0 | lib/fossilize/ring_buffer.rb |
fossilize-1.0.0 | lib/fossilize/ring_buffer.rb |