Class: Vizcore::DSL::MidiMapExecutor::ActionContext Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vizcore/dsl/midi_map_executor.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.

Runtime DSL context used while executing one ‘midi_map` action block.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scenes:, globals:) ⇒ ActionContext

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 ActionContext.

Parameters:

  • scenes (Hash)
  • globals (Hash)


135
136
137
138
139
# File 'lib/vizcore/dsl/midi_map_executor.rb', line 135

def initialize(scenes:, globals:)
  @scenes = scenes
  @globals = globals
  @actions = []
end

Instance Attribute Details

#actionsObject (readonly)

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.

Collected runtime actions emitted by DSL calls.



131
132
133
# File 'lib/vizcore/dsl/midi_map_executor.rb', line 131

def actions
  @actions
end

Instance Method Details

#set(key, value) ⇒ 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.

Parameters:

  • key (Symbol, String)
  • value (Object)


161
162
163
164
165
166
167
168
169
# File 'lib/vizcore/dsl/midi_map_executor.rb', line 161

def set(key, value)
  symbol_key = key.to_sym
  @globals[symbol_key] = value
  @actions << {
    type: :set_global,
    key: symbol_key,
    value: value
  }
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.

Parameters:

  • name (Symbol, String)
  • effect (Hash, nil) (defaults to: nil)


144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/vizcore/dsl/midi_map_executor.rb', line 144

def switch_scene(name, effect: nil)
  scene = @scenes[name.to_sym]
  return unless scene

  @actions << {
    type: :switch_scene,
    scene: {
      name: scene[:name],
      layers: scene[:layers].map { |layer| deep_dup(layer) }
    },
    effect: deep_dup(effect)
  }
end