module Timeless::Pomodoro
Constants
- BREAK
- BREAK_LONG
- INTERVAL
- WORKING
- WORKING_LONG
Public Class Methods
run_pomodoro_timer(total_mins, notes=nil)
click to toggle source
# 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 # some plugins like TMux and TerminalTitle rely on this [start, Time.now, notes] end