Class: Vizcore::DSL::Engine::KeyBindingBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vizcore/dsl/engine.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Builder object for ‘key` block internals.

Instance Method Summary collapse

Constructor Details

#initializeKeyBindingBuilder

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.

Returns a new instance of KeyBindingBuilder.



570
571
572
# File 'lib/vizcore/dsl/engine.rb', line 570

def initialize
  @action = nil
end

Instance Method Details

#blackout(value = nil, fade: nil, release: nil, color: nil) ⇒ void

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.

This method returns an undefined value.

Toggle browser blackout output.



590
591
592
# File 'lib/vizcore/dsl/engine.rb', line 590

def blackout(value = nil, fade: nil, release: nil, color: nil)
  live_control(:blackout, value, fade: fade, release: release, color: color)
end

#freeze(value = nil, fade: nil, release: nil) ⇒ void

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.

This method returns an undefined value.

Toggle browser freeze output.



597
598
599
# File 'lib/vizcore/dsl/engine.rb', line 597

def freeze(value = nil, fade: nil, release: nil)
  live_control(:freeze, value, fade: fade, release: release)
end

#live_control(control, value = nil, fade: nil, release: nil, color: nil) ⇒ void

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.

This method returns an undefined value.

Toggle a browser live control.

Parameters:

  • control (Symbol, String)
  • value (Object, nil) (defaults to: nil)

    target value; nil means UI-side toggle for keyboard/live mapping

Raises:

  • (ArgumentError)


606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
# File 'lib/vizcore/dsl/engine.rb', line 606

def live_control(control, value = nil, fade: nil, release: nil, color: nil)
  normalized = control.to_s.strip.downcase.to_sym
  raise ArgumentError, "unsupported live control: #{control}" unless %i[blackout freeze].include?(normalized)

  assign_action(type: :live_control, control: normalized)

  # Preserve explicit value and transition timings when provided by DSL authors.
  # `nil` is kept for UI-side toggles to avoid changing existing keyboard ergonomics.
  action = @action
  action[:value] = value unless value.nil?
  action[:fade] = normalize_control_transition(fade)
  action[:release] = normalize_control_transition(release)
  action[:color] = normalize_control_color(color) unless color.nil?
  action.delete(:fade) if action[:fade].nil?
  action.delete(:release) if action[:release].nil?
  action.delete(:color) if action[:color].nil?
end

#switch_scene(name, effect: nil) ⇒ void

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.

This method returns an undefined value.

Switch to a named scene when the key is pressed.

Parameters:

  • name (Symbol, String)

Raises:

  • (ArgumentError)


578
579
580
581
582
583
584
585
# File 'lib/vizcore/dsl/engine.rb', line 578

def switch_scene(name, effect: nil)
  scene_name = name.to_s.strip
  raise ArgumentError, "switch_scene scene must not be empty" if scene_name.empty?

  action = { type: :switch_scene, scene: scene_name }
  action[:effect] = effect unless effect.nil?
  assign_action(action)
end

#to_hHash

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.

Returns serialized key action.

Returns:

  • (Hash)

    serialized key action



625
626
627
# File 'lib/vizcore/dsl/engine.rb', line 625

def to_h
  @action || {}
end