Class: Bluepill::Util::RotationalArray
- Inherits:
-
Array
- Object
- Array
- Bluepill::Util::RotationalArray
- Defined in:
- lib/bluepill/util/rotational_array.rb
Instance Method Summary collapse
-
#initialize(size) ⇒ RotationalArray
constructor
A new instance of RotationalArray.
- #push(value) ⇒ Object (also: #<<)
Constructor Details
#initialize(size) ⇒ RotationalArray
Returns a new instance of RotationalArray.
4 5 6 7 8 |
# File 'lib/bluepill/util/rotational_array.rb', line 4 def initialize(size) @capacity = size super() # no size - intentionally end |
Instance Method Details
#push(value) ⇒ Object Also known as: <<
10 11 12 13 14 15 |
# File 'lib/bluepill/util/rotational_array.rb', line 10 def push(value) super(value) shift if length > @capacity self end |