Method: Cinch::Timer#initialize
- Defined in:
- lib/cinch/timer.rb
#initialize(bot, options, &block) ⇒ Timer
Returns a new instance of Timer.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cinch/timer.rb', line 64 def initialize(bot, , &block) = {:threaded => true, :shots => Float::INFINITY, :start_automatically => true, :stop_automatically => true}.merge() @bot = bot @interval = [:interval].to_f @threaded = [:threaded] @orig_shots = [:shots] # Setting @shots here so the attr_reader won't return nil @shots = @orig_shots @block = block @started = false @thread_group = ThreadGroup.new if [:start_automatically] @bot.on :connect, //, self do |m, timer| timer.start end end if [:stop_automatically] @bot.on :disconnect, //, self do |m, timer| timer.stop end end end |