Class: Drip::SimpleStore::AtticCache
- Inherits:
-
Object
- Object
- Drip::SimpleStore::AtticCache
- Defined in:
- lib/drip.rb
Instance Method Summary collapse
-
#initialize(n) ⇒ AtticCache
constructor
A new instance of AtticCache.
- #push(attic) ⇒ Object
Constructor Details
#initialize(n) ⇒ AtticCache
Returns a new instance of AtticCache.
207 208 209 210 211 |
# File 'lib/drip.rb', line 207 def initialize(n) @size = n @tail = 0 @ary = Array.new(n) end |
Instance Method Details
#push(attic) ⇒ Object
213 214 215 216 217 218 |
# File 'lib/drip.rb', line 213 def push(attic) @ary[@tail].forget if @ary[@tail] @ary[@tail] = attic @tail = (@tail + 1) % @size attic end |