class Blinker::Timer
Constants
- COUNTDOWN_SECONDS
- GREEN
- RED
- YELLOW
Public Class Methods
new(total_min = 5, spurt_min = 1)
click to toggle source
# File lib/blinker/timer.rb, line 11 def initialize(total_min = 5, spurt_min = 1) @total_sec = total_min.to_i * 60 @spurt_sec = spurt_min.to_i * 60 @blink1 = Blink1.new @blink1.open end
Public Instance Methods
start()
click to toggle source
# File lib/blinker/timer.rb, line 18 def start in_progress last_spurt countdown finish end
Private Instance Methods
countdown()
click to toggle source
# File lib/blinker/timer.rb, line 37 def countdown @blink1.blink(*RED, COUNTDOWN_SECONDS) end
finish()
click to toggle source
# File lib/blinker/timer.rb, line 41 def finish @blink1.off @blink1.close end
in_progress()
click to toggle source
# File lib/blinker/timer.rb, line 27 def in_progress @blink1.fade_to_rgb(300, *GREEN) sleep @total_sec - @spurt_sec end
last_spurt()
click to toggle source
# File lib/blinker/timer.rb, line 32 def last_spurt @blink1.fade_to_rgb(300, *YELLOW) sleep (@spurt_sec - COUNTDOWN_SECONDS) end