Class: Cognizant::Util::RotationalArray
- Inherits:
-
Array
- Object
- Array
- Cognizant::Util::RotationalArray
- Defined in:
- lib/cognizant/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 |
# File 'lib/cognizant/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: <<
9 10 11 12 13 |
# File 'lib/cognizant/util/rotational_array.rb', line 9 def push(value) super(value) self.shift if self.length > @capacity self end |