Module: EventMachine

Defined in:
lib/jstd-runner.rb

Class Method Summary collapse

Class Method Details

.daily(at, &blk) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jstd-runner.rb', line 31

def self.daily at, &blk
  time = Time.parse(at) - Time.now
  time += 86400 if time < 0

  EM.run do
    run_me = proc{
      EM.add_timer(86400, run_me)
      blk.call
    }
    EM.add_timer(time, run_me)
  end
end