Class: Rpush::Daemon::RingBuffer

Inherits:
Array
  • Object
show all
Defined in:
lib/rpush/daemon/ring_buffer.rb

Instance Method Summary collapse

Constructor Details

#initialize(max_size) ⇒ RingBuffer

Returns a new instance of RingBuffer.



4
5
6
# File 'lib/rpush/daemon/ring_buffer.rb', line 4

def initialize(max_size)
  @max_size = max_size
end

Instance Method Details

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



8
9
10
11
# File 'lib/rpush/daemon/ring_buffer.rb', line 8

def <<(obj)
  shift if size >= @max_size
  super
end