14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/timeless/pomodoro.rb', line 14
def self.run_pomodoro_timer total_mins, notes=nil
start = Time.now
total_secs = total_mins * 60
s = 0
_s = nil
while true
s = (Time.now - start).to_i
r = total_secs - s
printf("\r%i:%02i", r / 60, r % 60) if s != _s
break if s >= total_secs
_s = s
sleep INTERVAL
end
print "\n"
notifier = Notiffany.connect(title: "Pomodoro Complete!")
notifier.notify("You clocked: #{total_mins} minute#{"s" if total_mins != 1}.\nYou deserve a break, now", image: :success)
notifier.disconnect
[start, Time.now, notes]
end
|