Class: RingBuffer
- Inherits:
-
Array
- Object
- Array
- RingBuffer
- Defined in:
- lib/active_event/support/ring_buffer.rb
Overview
simple ring buffer
Instance Attribute Summary collapse
-
#max_size ⇒ Object
Returns the value of attribute max_size.
Instance Method Summary collapse
- #<<(item) ⇒ Object (also: #push)
-
#initialize(max_size, *args, &block) ⇒ RingBuffer
constructor
A new instance of RingBuffer.
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_size ⇒ Object
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 |