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.



11
12
13
14
# File 'lib/wurk/limiter/points.rb', line 11

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].



18
19
20
21
# File 'lib/wurk/limiter/points.rb', line 18

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