Class: Fuzz::Cache

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

Instance Method Summary collapse

Constructor Details

#initialize(cache_file) ⇒ Cache



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

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

Instance Method Details

#increment(title) ⇒ Object



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

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

#weight(title) ⇒ Object



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

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