module PassAttempt
Constants
- VERSION
Public Instance Methods
check(condition, attemp)
click to toggle source
# File lib/pass_attempt.rb, line 15 def check(condition, attemp) case condition when :log2 Math.log2(attemp) == Math.log2(attemp).truncate when :log10 Math.log10(attemp) == Math.log10(attemp).truncate else condition.call(attemp) end end
incr(name)
click to toggle source
# File lib/pass_attempt.rb, line 10 def incr(name) @names ||= {} @names[name] = @names.fetch(name, 0) + 1 end
try(name, condition) { || ... }
click to toggle source
# File lib/pass_attempt.rb, line 6 def try(name, condition, &block) yield if check(condition, incr(name)) end