Class: Pomodoro

Inherits:
Object
  • Object
show all
Defined in:
lib/tmuxodoro/pomodoro.rb

Constant Summary collapse

MINUTE =
60

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tomatoes: nil, tomato_time: nil, rest_time: nil) ⇒ Pomodoro

Returns a new instance of Pomodoro.



6
7
8
9
10
# File 'lib/tmuxodoro/pomodoro.rb', line 6

def initialize(tomatoes: nil, tomato_time: nil, rest_time: nil)
  @tomatoes = tomatoes || 8
  @tomato_time = tomato_time || 25 * MINUTE
  @rest_time = rest_time || 5 * MINUTE
end

Instance Attribute Details

#rest_timeObject (readonly)

Returns the value of attribute rest_time.



4
5
6
# File 'lib/tmuxodoro/pomodoro.rb', line 4

def rest_time
  @rest_time
end

#stop_atObject (readonly)

Returns the value of attribute stop_at.



4
5
6
# File 'lib/tmuxodoro/pomodoro.rb', line 4

def stop_at
  @stop_at
end

#tomato_timeObject (readonly)

Returns the value of attribute tomato_time.



4
5
6
# File 'lib/tmuxodoro/pomodoro.rb', line 4

def tomato_time
  @tomato_time
end

#tomatoesObject (readonly)

Returns the value of attribute tomatoes.



4
5
6
# File 'lib/tmuxodoro/pomodoro.rb', line 4

def tomatoes
  @tomatoes
end

Instance Method Details

#startObject



24
25
26
27
# File 'lib/tmuxodoro/pomodoro.rb', line 24

def start
  @tomatoes -= 1
  @stop_at = Time.now + tomato_time
end

#statusObject



12
13
14
15
16
17
18
19
20
21
22
# 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
    "🍅  #{tomatoes}\n"
  end
end