Class: Bluepill::Util::RotationalArray

Inherits:
Array
  • Object
show all
Defined in:
lib/bluepill/util/rotational_array.rb

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ RotationalArray

Returns a new instance of RotationalArray.



5
6
7
8
9
# File 'lib/bluepill/util/rotational_array.rb', line 5

def initialize(size)
  @capacity = size

  super() # no size - intentionally
end

Instance Method Details

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



11
12
13
14
15
16
# File 'lib/bluepill/util/rotational_array.rb', line 11

def push(value)
  super(value)

  self.shift if self.length > @capacity
  self
end