class Hiatus::PercentageThreshold

Constants

DEFAULT_PERCENTAGE

Public Class Methods

new(failure_percentage = DEFAULT_PERCENTAGE) click to toggle source
# File lib/hiatus/percentage_threshold.rb, line 6
def initialize(failure_percentage = DEFAULT_PERCENTAGE)
  @failure_percentage = failure_percentage
  @failure_count = 0.0
  @total_calls = 0.0
end

Public Instance Methods

increment() click to toggle source
# File lib/hiatus/percentage_threshold.rb, line 12
def increment
  @failure_count += 1
end
reached?() click to toggle source
# File lib/hiatus/percentage_threshold.rb, line 25
def reached?
  @failure_count / @total_calls > @failure_percentage
end
reset() click to toggle source
# File lib/hiatus/percentage_threshold.rb, line 20
def reset
  @failure_count = 0
  @total_calls = 0
end
touch() click to toggle source
# File lib/hiatus/percentage_threshold.rb, line 16
def touch
  @total_calls += 1
end