class Pomodoro
Constants
- MINUTE
Attributes
initial_tomatoes[R]
rest_time[R]
stop_at[R]
tomato_time[R]
tomatoes[R]
Public Class Methods
new(tomatoes: nil, tomato_time: nil, rest_time: nil)
click to toggle source
# File lib/tmuxodoro/pomodoro.rb, line 6 def initialize(tomatoes: nil, tomato_time: nil, rest_time: nil) @tomatoes = @initial_tomatoes = tomatoes || 8 @tomato_time = tomato_time || 25 * MINUTE @rest_time = rest_time || 5 * MINUTE end
Public Instance Methods
start()
click to toggle source
# File lib/tmuxodoro/pomodoro.rb, line 24 def start @tomatoes = initial_tomatoes if tomatoes == 0 @tomatoes -= 1 @stop_at = Time.now + tomato_time end
status()
click to toggle source
# File lib/tmuxodoro/pomodoro.rb, line 12 def status if is_active? if work_time? "work: #{remaining_work_time} min\n" else "rest: #{remaining_rest_time} min\n" end else remain_tomatoes_status end end
Private Instance Methods
is_active?()
click to toggle source
# File lib/tmuxodoro/pomodoro.rb, line 32 def is_active? stop_at && Time.now < stop_at + rest_time end
remain_tomatoes_status()
click to toggle source
# File lib/tmuxodoro/pomodoro.rb, line 50 def remain_tomatoes_status tomatoes > 0 ? "🍅 #{tomatoes}\n" : "work is done\n" end
remaining_rest_time()
click to toggle source
# File lib/tmuxodoro/pomodoro.rb, line 45 def remaining_rest_time return unless stop_at ((stop_at + rest_time - Time.now) / MINUTE).ceil end
remaining_work_time()
click to toggle source
# File lib/tmuxodoro/pomodoro.rb, line 40 def remaining_work_time return unless stop_at ((stop_at - Time.now) / MINUTE).ceil end
work_time?()
click to toggle source
# File lib/tmuxodoro/pomodoro.rb, line 36 def work_time? Time.now < stop_at end