Module: Amigo::ScheduledJob::ClassMethods
- Defined in:
- lib/amigo/scheduled_job.rb
Instance Attribute Summary collapse
-
#cron_expr ⇒ Object
Returns the value of attribute cron_expr.
-
#splay_duration ⇒ Object
Returns the value of attribute splay_duration.
Instance Method Summary collapse
- #cron(expr) ⇒ Object
- #event_job? ⇒ Boolean
- #scheduled_job? ⇒ Boolean
- #splay(duration) ⇒ Object
-
#utc_hour(hour, tzstr) ⇒ Object
Return the UTC hour for the given hour and timezone.
Instance Attribute Details
#cron_expr ⇒ Object
Returns the value of attribute cron_expr.
38 39 40 |
# File 'lib/amigo/scheduled_job.rb', line 38 def cron_expr @cron_expr end |
#splay_duration ⇒ Object
Returns the value of attribute splay_duration.
38 39 40 |
# File 'lib/amigo/scheduled_job.rb', line 38 def splay_duration @splay_duration end |
Instance Method Details
#cron(expr) ⇒ Object
62 63 64 |
# File 'lib/amigo/scheduled_job.rb', line 62 def cron(expr) self.cron_expr = expr end |
#event_job? ⇒ Boolean
44 45 46 |
# File 'lib/amigo/scheduled_job.rb', line 44 def event_job? return false end |
#scheduled_job? ⇒ Boolean
40 41 42 |
# File 'lib/amigo/scheduled_job.rb', line 40 def scheduled_job? return true end |
#splay(duration) ⇒ Object
66 67 68 |
# File 'lib/amigo/scheduled_job.rb', line 66 def splay(duration) self.splay_duration = duration end |
#utc_hour(hour, tzstr) ⇒ Object
Return the UTC hour for the given hour and timezone. For example, during DST, ‘utc_hour(6, ’US/Pacific’)‘ returns 13 (or, 6 + 7), while in standard time (not DST) it returns 8 (or, 6 + 8). This is useful in crontab notation, when we want something to happen at a certain local time and don’t want it to shift with DST.
53 54 55 56 57 58 59 60 |
# File 'lib/amigo/scheduled_job.rb', line 53 def utc_hour(hour, tzstr) local = TZInfo::Timezone.get(tzstr) utc = TZInfo::Timezone.get("UTC") n = Time.now intz = Time.new(n.year, n.month, n.day, hour, n.min, n.sec, local) inutc = utc.to_local(intz) return inutc.hour end |