Sha256: 2e21d24b8251633676a2043c168aa2126d969ab1d5769d7def94dbfc55eeadb1
Contents?: true
Size: 640 Bytes
Versions: 2
Compression:
Stored size: 640 Bytes
Contents
module Backport module Server # A Backport periodical interval server. # class Interval < Base # @param period [Float] The interval time in seconds. # @param block [Proc] The proc to run on each interval. # @yieldparam [Interval] def initialize period, &block @period = period @block = block @last_time = Time.now end def starting @last_time = Time.now end def tick now = Time.now return unless now - @last_time >= @period @block.call self @last_time = now end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
backport-1.0.0 | lib/backport/server/interval.rb |
backport-0.3.0 | lib/backport/server/interval.rb |