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.
37 38 39 |
# File 'lib/amigo/scheduled_job.rb', line 37 def cron_expr @cron_expr end |
#splay_duration ⇒ Object
Returns the value of attribute splay_duration.
37 38 39 |
# File 'lib/amigo/scheduled_job.rb', line 37 def splay_duration @splay_duration end |
Instance Method Details
#cron(expr) ⇒ Object
61 62 63 |
# File 'lib/amigo/scheduled_job.rb', line 61 def cron(expr) self.cron_expr = expr end |
#event_job? ⇒ Boolean
43 44 45 |
# File 'lib/amigo/scheduled_job.rb', line 43 def event_job? return false end |
#scheduled_job? ⇒ Boolean
39 40 41 |
# File 'lib/amigo/scheduled_job.rb', line 39 def scheduled_job? return true end |
#splay(duration) ⇒ Object
65 66 67 |
# File 'lib/amigo/scheduled_job.rb', line 65 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.
52 53 54 55 56 57 58 59 |
# File 'lib/amigo/scheduled_job.rb', line 52 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 |