Class: Ledstrip::Strip

Inherits:
Object
  • Object
show all
Defined in:
lib/ledstrip/strip.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(led_count, type:) ⇒ Strip

Returns a new instance of Strip.



6
7
8
9
10
11
# File 'lib/ledstrip/strip.rb', line 6

def initialize(led_count, type:)
  @leds = []
  @type = type

  init_leds(led_count)
end

Instance Attribute Details

#effectObject

Returns the value of attribute effect.



4
5
6
# File 'lib/ledstrip/strip.rb', line 4

def effect
  @effect
end

#ledsObject

Returns the value of attribute leds.



4
5
6
# File 'lib/ledstrip/strip.rb', line 4

def leds
  @leds
end

Instance Method Details

#drawObject



19
20
21
# File 'lib/ledstrip/strip.rb', line 19

def draw
  @type.draw(@leds)
end

#set_effect(name, options = {}) ⇒ Object



13
14
15
16
17
# File 'lib/ledstrip/strip.rb', line 13

def set_effect(name, options={})
  @effect.stop if @effect
  @effect = Ledstrip::Effects.instantiate(self, name, options) 
  @effect.start
end

#sleep_timeObject



23
24
25
# File 'lib/ledstrip/strip.rb', line 23

def sleep_time
  @effect.sleep_time
end