Class: SimpleArrayEviction
- Inherits:
-
Object
- Object
- SimpleArrayEviction
- Defined in:
- lib/repositories/simple_array_eviction.rb
Overview
Creates a limited array with a FIFO.
Instance Attribute Summary collapse
-
#n ⇒ Object
Returns the value of attribute n.
Instance Method Summary collapse
-
#initialize(n = nil) ⇒ SimpleArrayEviction
constructor
A new instance of SimpleArrayEviction.
- #update(ary) ⇒ Object
Constructor Details
#initialize(n = nil) ⇒ SimpleArrayEviction
Returns a new instance of SimpleArrayEviction.
6 7 8 |
# File 'lib/repositories/simple_array_eviction.rb', line 6 def initialize(n=nil) @n = n || 10 end |
Instance Attribute Details
#n ⇒ Object
Returns the value of attribute n.
4 5 6 |
# File 'lib/repositories/simple_array_eviction.rb', line 4 def n @n end |
Instance Method Details
#update(ary) ⇒ Object
10 11 12 13 14 |
# File 'lib/repositories/simple_array_eviction.rb', line 10 def update(ary) while ary.size > self.n ary.nontainting_shift end end |