module Timeloop::Helper
Conveniences methods that provide access to the Timeloop
functionality to be included in other classes and modules.
Public Instance Methods
every(period, opts = {}, &blk)
click to toggle source
Provides a way to execute a block of code periodically. The runtime of the block is taken in to account so a delay in one run does not impact the start times of future runs.
Arguments
period - seconds or name of time period (eg, 'second', 'hour') between iterations
Options
max - the maximum number of executions of the block. Default: INFINITY maximum - synonym of `max` logger - logger to which debugging info should be sent. Default: no logging
Yields Integer
index of the iteration to the provide block every `period`.
# File lib/timeloop.rb, line 113 def every(period, opts = {}, &blk) Timeloop.new(opts.merge(period: period)).loop(&blk) end