Class: Fuzz::Cache
- Inherits:
-
Object
- Object
- Fuzz::Cache
- Defined in:
- lib/fuzz/cache.rb
Instance Method Summary collapse
- #increment(title) ⇒ Object
-
#initialize(cache_file) ⇒ Cache
constructor
A new instance of Cache.
- #weight(title) ⇒ Object
Constructor Details
#initialize(cache_file) ⇒ Cache
5 6 7 8 |
# File 'lib/fuzz/cache.rb', line 5 def initialize(cache_file) @cache_file = File.(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 |