Class: Wurk::Limiter::Points::Handle

Inherits:
Object
  • Object
show all
Defined in:
lib/wurk/limiter/points.rb

Instance Method Summary collapse

Constructor Details

#initialize(limiter, estimate) ⇒ Handle

Returns a new instance of Handle.



13
14
15
16
# File 'lib/wurk/limiter/points.rb', line 13

def initialize(limiter, estimate)
  @limiter = limiter
  @estimate = estimate
end

Instance Method Details

#points_used(actual) ⇒ Object

Positive delta returns points to the bucket; negative records an under-estimate. Either way, clamped to [0, cap].



20
21
22
23
# File 'lib/wurk/limiter/points.rb', line 20

def points_used(actual)
  delta = @estimate - actual
  @limiter.send(:refund, delta)
end