【发布时间】:2018-10-29 12:31:48
【问题描述】:
我已经为我正在计时的功能设置了一个计时器,但希望它在满足条件后重置
timestart = Time.now
Individual.all.each do |f|
endtime = Time.now
timer = (endtime - timestart)
puts timer #places the time it takes for each loop
if checktime == 1 then
###Apply new {timestart = Time.now} HERE?###
end
end
所以在上面的例子中,我希望我的计时器在 1 分钟后重置
【问题讨论】:
-
每 1 分钟后你到底想做什么?
-
到了1分钟就重置timestart,从而重置定时器
标签: ruby-on-rails ruby loops time