Class: InstJobsStatsd::Stats::Periodic::Timer
- Inherits:
-
Object
- Object
- InstJobsStatsd::Stats::Periodic::Timer
- Defined in:
- lib/inst_jobs_statsd/stats/periodic.rb
Instance Method Summary collapse
-
#initialize(min_interval) ⇒ Timer
constructor
A new instance of Timer.
-
#tick ⇒ Object
This is called as often as possible, based on the lifecycle callbacks.
Constructor Details
#initialize(min_interval) ⇒ Timer
Returns a new instance of Timer.
68 69 70 71 72 |
# File 'lib/inst_jobs_statsd/stats/periodic.rb', line 68 def initialize(min_interval) @min_interval = min_interval * 1.0 @start_time = Delayed::Job.db_time_now update_next_run end |
Instance Method Details
#tick ⇒ Object
This is called as often as possible, based on the lifecycle callbacks. When the required interval of time has passed, execute the given block
76 77 78 79 80 81 |
# File 'lib/inst_jobs_statsd/stats/periodic.rb', line 76 def tick return unless Delayed::Job.db_time_now >= @next_run update_next_run yield end |