Class: Musa::Clock::ExternalTickClock

Inherits:
Clock
  • Object
show all
Defined in:
lib/musa-dsl/transport/external-tick-clock.rb

Instance Method Summary collapse

Methods inherited from Clock

#on_change_position, #on_start, #on_stop, #running?

Constructor Details

#initialize(do_log: nil) ⇒ ExternalTickClock

Returns a new instance of ExternalTickClock.



6
7
8
9
10
11
12
# File 'lib/musa-dsl/transport/external-tick-clock.rb', line 6

def initialize(do_log: nil)
  do_log ||= false

  super()

  @do_log = do_log
end

Instance Method Details

#run(&block) ⇒ Object



14
15
16
17
18
# File 'lib/musa-dsl/transport/external-tick-clock.rb', line 14

def run(&block)
  @on_start.each(&:call)
  @run = true
  @block = block
end

#terminateObject



26
27
28
29
# File 'lib/musa-dsl/transport/external-tick-clock.rb', line 26

def terminate
  @on_stop.each(&:call)
  @run = false
end

#tickObject



20
21
22
23
24
# File 'lib/musa-dsl/transport/external-tick-clock.rb', line 20

def tick
  if @run
    @block.call if @block
  end
end