Class: Fuzz::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzz/cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(cache_file) ⇒ Cache

Returns a new instance of Cache.



4
5
6
7
# File 'lib/fuzz/cache.rb', line 4

def initialize(cache_file)
  @cache_file = File.expand_path(cache_file)
  @entries = cache_entries(@cache_file)
end

Instance Method Details

#increment!(title) ⇒ Object



13
14
15
16
# File 'lib/fuzz/cache.rb', line 13

def increment!(title)
  entries[title] = weight(title) + 1
  write
end

#weight(title) ⇒ Object



9
10
11
# File 'lib/fuzz/cache.rb', line 9

def weight(title)
  entries.fetch(title, 0)
end