Class: SimpleArrayEviction

Inherits:
Object
  • Object
show all
Defined in:
lib/repositories/simple_array_eviction.rb

Overview

Creates a limited array with a FIFO.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nObject

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