Class: RingBuffer

Inherits:
Array
  • Object
show all
Defined in:
lib/active_event/support/ring_buffer.rb

Overview

simple ring buffer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_size, *args, &block) ⇒ RingBuffer

Returns a new instance of RingBuffer.



5
6
7
8
# File 'lib/active_event/support/ring_buffer.rb', line 5

def initialize(max_size, *args, &block)
  super(*args, &block)
  self.max_size = max_size
end

Instance Attribute Details

#max_sizeObject

Returns the value of attribute max_size.



3
4
5
# File 'lib/active_event/support/ring_buffer.rb', line 3

def max_size
  @max_size
end

Instance Method Details

#<<(item) ⇒ Object Also known as: push



15
16
17
18
# File 'lib/active_event/support/ring_buffer.rb', line 15

def <<(item)
  shift if max_size && size == max_size
  super
end