Object
# File lib/counters/base.rb, line 6 def initialize(total) # Attempt to prevent causing an infinite loop by being very strict about # the value passed. unless total.is_a?(Fixnum) and total > 0 raise(ArgumentError, "invalid number of attempts: #{total.inspect}") end @total = total end
Called before each attempt to increment the counter.
# File lib/counters/base.rb, line 22 def increment @attempt += 1 log end
Returns true if this is the last attempt.
# File lib/counters/base.rb, line 28 def last_attempt? @attempt == @total end
Logs the current attempt count.
# File lib/counters/base.rb, line 33 def log return if @logger.nil? @logger.debug("Counter") { "attempt #{self}" } end
Generated with the Darkfish Rdoc Generator 2.