Class: BoardLinuxfr::Cache::Entry

Inherits:
Array
  • Object
show all
Defined in:
lib/board-linuxfr/cache.rb

Instance Method Summary collapse

Instance Method Details

#from(id, &blk) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/board-linuxfr/cache.rb', line 11

def from(id, &blk)
  found = false
  each do |item|
    blk.call item if found
    found ||= item[:id] == id
  end
end

#push(item) ⇒ Object



6
7
8
9
# File 'lib/board-linuxfr/cache.rb', line 6

def push(item)
  super item
  shift if size > CAPACITY
end