Class: RubyBuzz::Light
- Inherits:
-
Object
- Object
- RubyBuzz::Light
- Defined in:
- lib/ruby_buzz/light.rb
Overview
Each Pad has one LED light under the buzzer button.
There are four Light objects, each controls one of these lights.
Accessed via Pad:
‘RubyBuzz::Pad.light`
Controlled individually:
-
‘RubyBuzz::Pad.light.on`
-
‘RubyBuzz::Pad.light.off`
Controlled together:
-
RubyBuzz::Light.all_on
-
RubyBuzz::Light.all_off
Constant Summary collapse
- @@lights =
[]
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Class Method Summary collapse
-
.all_off ⇒ Object
Turn all lights off.
-
.all_on ⇒ Object
Turn all lights on.
Instance Method Summary collapse
-
#initialize(index) ⇒ Light
constructor
Initialize a buzzer by index 0 to 3.
-
#off ⇒ Object
Turn the light off.
-
#on ⇒ Object
Turn the light on.
Constructor Details
#initialize(index) ⇒ Light
Initialize a buzzer by index 0 to 3.
Arguments:
-
index - Integer, 0 to 3, which light does this represent.
33 34 35 36 |
# File 'lib/ruby_buzz/light.rb', line 33 def initialize(index) @file = `ls /sys/class/leds/*buzz#{index + 1}/brightness` @@lights << self end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
24 25 26 |
# File 'lib/ruby_buzz/light.rb', line 24 def file @file end |
Class Method Details
.all_off ⇒ Object
Turn all lights off
57 58 59 60 |
# File 'lib/ruby_buzz/light.rb', line 57 def self.all_off @@lights.each{|l|l.off} return nil end |
.all_on ⇒ Object
Turn all lights on
65 66 67 68 |
# File 'lib/ruby_buzz/light.rb', line 65 def self.all_on @@lights.each{|l|l.on } return nil end |
Instance Method Details
#off ⇒ Object
Turn the light off
49 50 51 52 |
# File 'lib/ruby_buzz/light.rb', line 49 def off `echo 0 > #{file}` return nil end |
#on ⇒ Object
Turn the light on
41 42 43 44 |
# File 'lib/ruby_buzz/light.rb', line 41 def on `echo 1 > #{file}` return nil end |