Class: OpenHAB::DSL::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/openhab/dsl/timers/timer.rb

Instance Method Summary collapse

Constructor Details

#initialize(duration:, thread_locals: {}, &block) ⇒ Timer

Create a new Timer Object

Parameters:

  • duration (Duration)

    Duration until timer should fire

  • block (Block)

    Block to execute when timer fires



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

#cancelBoolean

Cancel timer

Returns:

  • (Boolean)

    True if cancel was successful, false otherwise



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

Returns:

  • (Boolean)


34
# File 'lib/rspec/openhab/dsl/timers/timer.rb', line 34

def terminated?; end