Class: SparkleMotion::LightConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/sparkle_motion/utility.rb

Overview

Class to represent configurations and positioning of lights.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:, group:) ⇒ LightConfig

Returns a new instance of LightConfig.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sparkle_motion/utility.rb', line 17

def initialize(config:, group:)
  group_config  = config[group]
  num_lights    = group_config.length

  lights_by_bridge  = group_lights_by_bridge(group_config)

  index           = 0
  masks_by_bridge = {}
  lights_by_bridge.each do |(bridge_name, lights)|
    lights_by_bridge[bridge_name], index = index_lights(lights, index)
    masks_by_bridge[bridge_name] = mask_lights(lights_by_bridge[bridge_name], num_lights)
  end

  set_state!(config, lights_by_bridge, masks_by_bridge)
end

Instance Attribute Details

#bridgesObject

Returns the value of attribute bridges.



15
16
17
# File 'lib/sparkle_motion/utility.rb', line 15

def bridges
  @bridges
end

#lightsObject

Returns the value of attribute lights.



15
16
17
# File 'lib/sparkle_motion/utility.rb', line 15

def lights
  @lights
end

#masksObject

Returns the value of attribute masks.



15
16
17
# File 'lib/sparkle_motion/utility.rb', line 15

def masks
  @masks
end