class BBB::Components::Led

The LED class is the component interface into a digital pin. In a way it’s nothing more than a straight forward port of a digital pin. You can use a led component when you want to use digital pins, or simply define your own class and extend it from the LED.

The Led class does not perform any sort of caching or smart calls, it forwards everything to the pin. In your own applications you might want to tune this behavior by adding some kind of caching.

Public Instance Methods

off!() click to toggle source

Turns off the LED @return void

# File lib/BBB/components/led.rb, line 30
def off!
  pin.off!
end
off?() click to toggle source

Checks if the LED is turned off.

@return Boolean

# File lib/BBB/components/led.rb, line 48
def off?
  pin.off?
end
on!() click to toggle source

Turns on the LED @return void

# File lib/BBB/components/led.rb, line 22
def on!
  pin.on!
end
on?() click to toggle source

Checks if the LED is turned on.

@return Boolean

# File lib/BBB/components/led.rb, line 39
def on?
  pin.on?
end
status() click to toggle source

Returns the status of the current led

# File lib/BBB/components/led.rb, line 56
def status
  on? ? :on : :off
end
toggle!() click to toggle source

Toggle the led between on and off

# File lib/BBB/components/led.rb, line 63
def toggle!
  if on?
    off!
  elsif off?
    on!
  end
end