Class: Riak::Client::Decaying
Instance Attribute Summary (collapse)
-
- (Object) e
A float which decays exponentially with time.
-
- (Object) p
Returns the value of attribute p.
Instance Method Summary (collapse)
-
- (Object) <<(d)
Add d to current value.
- - (Decaying) initialize(opts = {}) constructor
-
- (Object) value
Return current value.
Constructor Details
Instance Attribute Details
- (Object) e
A float which decays exponentially with time.
4 5 6 |
# File 'lib/riak/client/decaying.rb', line 4 def e @e end |
- (Object) p
Returns the value of attribute p
5 6 7 |
# File 'lib/riak/client/decaying.rb', line 5 def p @p end |
Instance Method Details
- (Object) <<(d)
Add d to current value.
17 18 19 |
# File 'lib/riak/client/decaying.rb', line 17 def <<(d) @p = value + d end |
- (Object) value
Return current value
22 23 24 25 26 27 |
# File 'lib/riak/client/decaying.rb', line 22 def value now = Time.now dt = now - @t0 @t0 = now @p = @p * (@e ** (@r * dt)) end |