Class: Musa::Clock::DummyClock
- Defined in:
- lib/musa-dsl/transport/dummy-clock.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#ticks ⇒ Object
Returns the value of attribute ticks.
Instance Method Summary collapse
-
#initialize(ticks = nil, do_log: nil, &block) ⇒ DummyClock
constructor
A new instance of DummyClock.
- #run ⇒ Object
- #terminate ⇒ Object
Methods inherited from Clock
#on_change_position, #on_start, #on_stop, #running?
Constructor Details
#initialize(ticks = nil, do_log: nil, &block) ⇒ DummyClock
Returns a new instance of DummyClock.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/musa-dsl/transport/dummy-clock.rb', line 6 def initialize(ticks = nil, do_log: nil, &block) do_log ||= false super() raise ArgumentError, 'Cannot initialize with ticks and block. You can only use one of the parameters.' if ticks && block @ticks = ticks @do_log = do_log @block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
18 19 20 |
# File 'lib/musa-dsl/transport/dummy-clock.rb', line 18 def block @block end |
#ticks ⇒ Object
Returns the value of attribute ticks.
18 19 20 |
# File 'lib/musa-dsl/transport/dummy-clock.rb', line 18 def ticks @ticks end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/musa-dsl/transport/dummy-clock.rb', line 20 def run @on_start.each(&:call) @run = true while @run && eval_condition yield if block_given? Thread.pass end @on_stop.each(&:call) end |
#terminate ⇒ Object
33 34 35 |
# File 'lib/musa-dsl/transport/dummy-clock.rb', line 33 def terminate @run = false end |