class GoFlippy::Worker
Public Class Methods
create(interval) { || ... }
click to toggle source
# File lib/goflippy-ruby/worker.rb, line 7 def self.create(interval, &block) Thread.new do loop do begin started_at = Time.now yield sleep(interval) if (interval - (Time.now - started_at)).positive? rescue StandardError => e Logger.error(e) end end end end