Class: Tomate::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/tomate/timer.rb

Constant Summary collapse

DEFAULT_DELAY =
25*60

Instance Method Summary collapse

Constructor Details

#initialize(delay) ⇒ Timer

Returns a new instance of Timer.



5
6
7
# File 'lib/tomate/timer.rb', line 5

def initialize(delay)
  @delay = Integer(delay || DEFAULT_DELAY)
end

Instance Method Details

#startObject



9
10
11
12
13
14
15
16
17
# File 'lib/tomate/timer.rb', line 9

def start
  pid = fork do
    Kernel.system('notify-send', '-i', POMODORO_PNG, 'Pomodoro', "Timer started: #{@delay} seconds.")
    sleep @delay
    Kernel.system('notify-send', '-u', 'critical', '-t', '60000', '-i',POMODORO_PNG, 'Pomodoro', 'Take a break, nerd!')
  end

  Process.detach(pid)
end