class LanguageCards::Timer
Public Class Methods
new()
click to toggle source
# File lib/language_cards/timer.rb, line 4 def initialize @stamps = [] @mark = nil end
Public Instance Methods
average()
click to toggle source
# File lib/language_cards/timer.rb, line 25 def average total.fdiv(times.size) end
h()
click to toggle source
# File lib/language_cards/timer.rb, line 21 def h # human "%02d:%02d:%02d" % [total/3600%24, total/60%60, total%60] end
ha()
click to toggle source
# File lib/language_cards/timer.rb, line 29 def ha # human average "%0.2f #{I18n.t('Timer.AverageSeconds')}" % average rescue "" end
last()
click to toggle source
# File lib/language_cards/timer.rb, line 37 def last @stamps.last end
mark()
click to toggle source
# File lib/language_cards/timer.rb, line 9 def mark if @mark @stamps << -(@mark - (@mark = Time.now)) else @mark = Time.now end end
time?()
click to toggle source
# File lib/language_cards/timer.rb, line 17 def time? !times.empty? end
times()
click to toggle source
# File lib/language_cards/timer.rb, line 33 def times @stamps end
total()
click to toggle source
# File lib/language_cards/timer.rb, line 41 def total @stamps.inject(:+) || 0 end