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
Returns a new instance of Cache.
4 5 6 7 |
# File 'lib/fuzz/cache.rb', line 4 def initialize(cache_file) @cache_file = File.(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 |