Class: Telegram::Watcher
- Inherits:
-
Object
- Object
- Telegram::Watcher
- Defined in:
- lib/telegram/authorization.rb
Instance Method Summary collapse
- #call_after(sec) ⇒ Object
-
#initialize(&block) ⇒ Watcher
constructor
A new instance of Watcher.
- #stop ⇒ Object
Constructor Details
#initialize(&block) ⇒ Watcher
Returns a new instance of Watcher.
81 82 83 84 |
# File 'lib/telegram/authorization.rb', line 81 def initialize(&block) @thread = nil @block = block end |
Instance Method Details
#call_after(sec) ⇒ Object
86 87 88 89 |
# File 'lib/telegram/authorization.rb', line 86 def call_after(sec) stop @thread = Thread.new { sleep(sec); @block.call } end |
#stop ⇒ Object
91 92 93 |
# File 'lib/telegram/authorization.rb', line 91 def stop @thread.exit if @thread && @thread.alive? end |