Class: Musa::Sequencer::BaseSequencer::MoveControl
- Inherits:
-
EventHandler
- Object
- EventHandler
- Musa::Sequencer::BaseSequencer::MoveControl
- Defined in:
- lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb
Overview
Control object for move operations.
Wraps EveryControl to provide move-specific lifecycle management. Delegates timing control to EveryControl while adding move-specific callbacks and state.
Delegation Pattern
MoveControl delegates to EveryControl for:
- Duration and till timing control
- Iteration scheduling
- Stop conditions
Adds move-specific features:
- on_stop callbacks when movement completes
- after callbacks with delays
- Stopped state synchronization
Instance Attribute Summary collapse
-
#do_after ⇒ Array<Hash>
readonly
After callbacks with delays.
-
#do_on_stop ⇒ Array<Proc>
readonly
Stop callbacks.
-
#every_control ⇒ EveryControl
readonly
Underlying every control for timing.
Instance Method Summary collapse
-
#after(bars = nil) { ... } ⇒ void
Registers callback to execute after movement terminates naturally.
-
#initialize(parent, duration: nil, till: nil, on_stop: nil, after_bars: nil, after: nil) ⇒ MoveControl
constructor
private
Creates move control with timing parameters.
-
#manually_stopped? ⇒ Boolean
Checks if movement was stopped manually (via .stop).
-
#on_stop { ... } ⇒ void
Registers callback for when movement stops (any reason, including manual stop).
-
#stop ⇒ void
Stops movement manually.
-
#stopped? ⇒ Boolean
Checks if movement is stopped.
Constructor Details
#initialize(parent, duration: nil, till: nil, on_stop: nil, after_bars: nil, after: nil) ⇒ MoveControl
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates move control with timing parameters.
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 528 def initialize(parent, duration: nil, till: nil, on_stop: nil, after_bars: nil, after: nil) super parent @every_control = EveryControl.new(self, duration: duration, till: till) @manually_stopped = false @do_on_stop = [] @do_after = [] @do_on_stop << on_stop if on_stop self.after , &after if after @every_control.on_stop do @stop = true @do_on_stop.each(&:call) end end |
Instance Attribute Details
#do_after ⇒ Array<Hash> (readonly)
Returns after callbacks with delays.
516 517 518 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 516 def do_after @do_after end |
#do_on_stop ⇒ Array<Proc> (readonly)
Returns stop callbacks.
514 515 516 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 514 def do_on_stop @do_on_stop end |
#every_control ⇒ EveryControl (readonly)
Returns underlying every control for timing.
512 513 514 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 512 def every_control @every_control end |
Instance Method Details
#after(bars = nil) { ... } ⇒ void
This method returns an undefined value.
Registers callback to execute after movement terminates naturally. NOT called on manual stop (.stop).
567 568 569 570 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 567 def after( = nil, &block) ||= 0 @do_after << { bars: .rationalize, block: block } end |
#manually_stopped? ⇒ Boolean
Checks if movement was stopped manually (via .stop).
588 589 590 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 588 def manually_stopped? @manually_stopped end |
#on_stop { ... } ⇒ void
This method returns an undefined value.
Registers callback for when movement stops (any reason, including manual stop).
552 553 554 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 552 def on_stop(&block) @do_on_stop << block end |
#stop ⇒ void
This method returns an undefined value.
Stops movement manually.
Sets manually_stopped flag before delegating to every_control. After callbacks will NOT fire on manual stop.
579 580 581 582 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 579 def stop @manually_stopped = true @every_control.stop end |
#stopped? ⇒ Boolean
Checks if movement is stopped.
596 597 598 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 596 def stopped? @stop end |