Sha256: 83b820128627f47231e9947e98492149975fe6a3c1b0d52feb779c7a32f3334f
Contents?: true
Size: 677 Bytes
Versions: 6
Compression:
Stored size: 677 Bytes
Contents
module Instrumental class Intervalometer def initialize(period=60.0) @period = period.to_f @running = true @run_next = Time.now end def halt # TODO: See if it would be possible for the intervalometer to do a # final run before the thread exits. @running = false end # Runs a passed block at intervals defined by the period set during # initialization. Uses intervalometer to keep reasonably precise intervals. def run while @running if Time.now < @run_next sleep @run_next - Time.now end @run_next = Time.now + @period yield end end # run end end
Version data entries
6 entries across 6 versions & 1 rubygems