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.
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 532 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.
520 521 522 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 520 def do_after @do_after end |
#do_on_stop ⇒ Array<Proc> (readonly)
Returns stop callbacks.
518 519 520 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 518 def do_on_stop @do_on_stop end |
#every_control ⇒ EveryControl (readonly)
Returns underlying every control for timing.
516 517 518 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 516 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).
571 572 573 574 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 571 def after( = nil, &block) ||= 0 @do_after << { bars: .rationalize, block: block } end |
#manually_stopped? ⇒ Boolean
Checks if movement was stopped manually (via .stop).
592 593 594 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 592 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).
556 557 558 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 556 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.
583 584 585 586 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 583 def stop @manually_stopped = true @every_control.stop end |
#stopped? ⇒ Boolean
Checks if movement is stopped.
600 601 602 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb', line 600 def stopped? @stop end |