Class: TimerAbilities::Schedule
- Inherits:
-
Object
- Object
- TimerAbilities::Schedule
- Includes:
- SlackRubyBot::Loggable
- Defined in:
- src/abilities/timer_abilities.rb
Instance Method Summary collapse
-
#at(time, method, *args, save: true) ⇒ void
Schedule an action to be run once at the given time.
-
#cron(time, method, *args, save: false) ⇒ void
Schedule an action to be run at every interval described by a cron string.
-
#every(interval, method, *args, save: false) ⇒ void
Schedule an action to be run every interval.
Instance Method Details
#at(time, method, *args, save: true) ⇒ void
This method returns an undefined value.
Schedule an action to be run once at the given time
The action will inherit the context in which the timer was set. This means the current channel, thread and initiating user will all be accessible from inside the action.
40 41 42 43 |
# File 'src/abilities/timer_abilities.rb', line 40 def at(time, method, *args, save: true) logger.info "Scheduled #{method}(#{args.inspect}) at #{time}" @skill.schedule @context, time, method, args, save: save end |
#cron(time, method, *args, save: false) ⇒ void
This method returns an undefined value.
Schedule an action to be run at every interval described by a cron string
91 92 93 94 |
# File 'src/abilities/timer_abilities.rb', line 91 def cron(time, method, *args, save: false) logger.info "Scheduled #{method}(#{args.inspect}) at cron #{time}" @skill.schedule_cron @context, time, method, args, save: save end |
#every(interval, method, *args, save: false) ⇒ void
This method returns an undefined value.
Schedule an action to be run every interval
66 67 68 69 |
# File 'src/abilities/timer_abilities.rb', line 66 def every(interval, method, *args, save: false) logger.info "Scheduled #{method}(#{args.inspect}) every #{interval}" @skill.shedule_interval @context, interval, method, args, save: save end |