Module: Taimukun
- Defined in:
- lib/pomodorokun/taimukun.rb
Class Method Summary collapse
- .countdown(callback_name, text, sec, type) ⇒ Object
- .play_sound(sec, type) ⇒ Object
- .start_break ⇒ Object
- .start_work ⇒ Object
Class Method Details
.countdown(callback_name, text, sec, type) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pomodorokun/taimukun.rb', line 12 def countdown callback_name, text, sec, type while sec != 0 do sec -= 1 output = "#{sec / 60} : #{sec % 60}" print "\033[2K#{text} #{output}\033[100D" play_sound(sec, type) sleep 1 end send callback_name end |
.play_sound(sec, type) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pomodorokun/taimukun.rb', line 25 def play_sound(sec, type) if sec == 6 Open3.popen3 ("afplay #{File.('../../sound/countdown.mp3', __FILE__)}") end if type == :working && sec == 2 Open3.popen3 ("afplay #{File.('../../sound/private.mp3', __FILE__)}") end if type == :breaking && sec == 2 Open3.popen3 ("afplay #{File.('../../sound/menso-re.mp3', __FILE__)}") end end |
.start_break ⇒ Object
8 9 10 |
# File 'lib/pomodorokun/taimukun.rb', line 8 def start_break countdown 'start_work', 'break time!!!', 300, :breaking end |
.start_work ⇒ Object
4 5 6 |
# File 'lib/pomodorokun/taimukun.rb', line 4 def start_work countdown 'start_break', 'now working...', 1500, :working end |