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.
229 230 231 232 233 |
# File 'lib/drip.rb', line 229 def initialize(n) @size = n @tail = 0 @ary = Array.new(n) end |
Instance Method Details
#push(attic) ⇒ Object
235 236 237 238 239 240 |
# File 'lib/drip.rb', line 235 def push(attic) @ary[@tail].forget if @ary[@tail] @ary[@tail] = attic @tail = (@tail + 1) % @size attic end |