Class: ForgetTable::Decay
- Inherits:
-
Object
- Object
- ForgetTable::Decay
- Defined in:
- lib/forget_table/decay.rb
Constant Summary collapse
- DEFAULT_DECAY_RATE =
0.2
Instance Method Summary collapse
- #decay_value(value) ⇒ Object
-
#initialize(last_updated, rate = DEFAULT_DECAY_RATE) ⇒ Decay
constructor
-
last_updated: timestamp of the last update - rate: the rate of the decay (optional).
-
Constructor Details
#initialize(last_updated, rate = DEFAULT_DECAY_RATE) ⇒ Decay
-
last_updated: timestamp of the last update
-
rate: the rate of the decay (optional)
9 10 11 12 |
# File 'lib/forget_table/decay.rb', line 9 def initialize(last_updated, rate = DEFAULT_DECAY_RATE) @last_updated = last_updated @rate = rate end |
Instance Method Details
#decay_value(value) ⇒ Object
14 15 16 17 |
# File 'lib/forget_table/decay.rb', line 14 def decay_value(value) decayed_value = value - decay_for(value) decayed_value > 0 ? decayed_value : 1 end |