Sha256: 169b197fd7c6634229da72a88f78f27a5e9ffba00a45812f37c1d0084c17843c
Contents?: true
Size: 464 Bytes
Versions: 24
Compression:
Stored size: 464 Bytes
Contents
class Infobar::Frequency def initialize(duration) @duration = duration.to_f @called = 0 end attr_reader :duration attr_reader :called def update(now: Time.now) @update = now @called += 1 end def call(&block) now = Time.now if !@update || now - @update > @duration update now: now block.call end end def reset @update = nil @called = 0 self end def to_s @duration.to_s end end
Version data entries
24 entries across 24 versions & 1 rubygems