Class: GuardBlink1
- Inherits:
-
Object
- Object
- GuardBlink1
- Defined in:
- lib/guard_blink1.rb
Constant Summary collapse
- COLOURS =
{ 'success' => '#0F0', 'failed' => '#F00', 'pending' => '#FFC300', 'off' => '#000', 'default' => '#777', }
Class Method Summary collapse
Class Method Details
.blink_colour(status) ⇒ Object
15 16 17 18 |
# File 'lib/guard_blink1.rb', line 15 def blink_colour(status) colour = get_colour(status) set_colour(colour) end |
.get_colour(status) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/guard_blink1.rb', line 20 def get_colour(status) colour = COLOURS.fetch(status) do |key| begin key.to_color; key rescue ArgumentError, NoMethodError COLOURS['default'] end end end |
.set_colour(colour) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/guard_blink1.rb', line 30 def set_colour(colour) rgb = ColorMath::hex_color(colour) r,g,b = (rgb.red * 255), (rgb.green * 255), (rgb.blue * 255) Blink1.open do |blink1| blink1.set_rgb(r,g,b) end rgb end |