Class: OpenHAB::DSL::Timer
- Inherits:
-
Object
- Object
- OpenHAB::DSL::Timer
- Defined in:
- lib/rspec/openhab/dsl/timers/timer.rb
Instance Method Summary collapse
-
#cancel ⇒ Boolean
Cancel timer.
-
#initialize(duration:, thread_locals: {}, &block) ⇒ Timer
constructor
Create a new Timer Object.
- #reschedule(duration = nil) ⇒ Object
- #terminated? ⇒ Boolean (also: #has_terminated)
Constructor Details
#initialize(duration:, thread_locals: {}, &block) ⇒ Timer
Create a new Timer Object
12 13 14 15 16 |
# File 'lib/rspec/openhab/dsl/timers/timer.rb', line 12 def initialize(duration:, thread_locals: {}, &block) # rubocop:disable Lint/UnusedMethodArgument @duration = duration Timers.timer_manager.add(self) end |
Instance Method Details
#cancel ⇒ Boolean
Cancel timer
30 31 32 |
# File 'lib/rspec/openhab/dsl/timers/timer.rb', line 30 def cancel Timers.timer_manager.delete(self) end |
#reschedule(duration = nil) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/rspec/openhab/dsl/timers/timer.rb', line 18 def reschedule(duration = nil) duration ||= @duration Timers.timer_manager.add(self) reschedule(OpenHAB::DSL.to_zdt(duration)) end |
#terminated? ⇒ Boolean Also known as: has_terminated
34 |
# File 'lib/rspec/openhab/dsl/timers/timer.rb', line 34 def terminated?; end |