class OmniBot::AttemptCounter

Helper class for counting reconnect attempts

Public Class Methods

new(max_attempts) click to toggle source
# File lib/omnibot/helpers.rb, line 38
def initialize(max_attempts)
  @counter = 0
  @max_attempts = max_attempts
  OmniLog::debug 'AttemptCounter inited'
end

Public Instance Methods

increase() click to toggle source
# File lib/omnibot/helpers.rb, line 48
def increase
  @counter += 1
  report
end
out_of_attempts?() click to toggle source
# File lib/omnibot/helpers.rb, line 44
def out_of_attempts?
  @counter >= @max_attempts
end
report() click to toggle source
# File lib/omnibot/helpers.rb, line 32
def report
  OmniLog::debug "AttemptCounter: try #{@counter} of #{@max_attempts}"
end