Class: Pomodoro
- Inherits:
-
Object
- Object
- Pomodoro
- Defined in:
- lib/tmuxodoro/pomodoro.rb
Constant Summary collapse
- MINUTE =
60
Instance Attribute Summary collapse
-
#rest_time ⇒ Object
readonly
Returns the value of attribute rest_time.
-
#stop_at ⇒ Object
readonly
Returns the value of attribute stop_at.
-
#tomato_time ⇒ Object
readonly
Returns the value of attribute tomato_time.
-
#tomatoes ⇒ Object
readonly
Returns the value of attribute tomatoes.
Instance Method Summary collapse
-
#initialize(tomatoes: nil, tomato_time: nil, rest_time: nil) ⇒ Pomodoro
constructor
A new instance of Pomodoro.
- #start ⇒ Object
- #status ⇒ Object
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_time ⇒ Object (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_at ⇒ Object (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_time ⇒ Object (readonly)
Returns the value of attribute tomato_time.
4 5 6 |
# File 'lib/tmuxodoro/pomodoro.rb', line 4 def tomato_time @tomato_time end |
#tomatoes ⇒ Object (readonly)
Returns the value of attribute tomatoes.
4 5 6 |
# File 'lib/tmuxodoro/pomodoro.rb', line 4 def tomatoes @tomatoes end |
Instance Method Details
#start ⇒ Object
24 25 26 27 |
# File 'lib/tmuxodoro/pomodoro.rb', line 24 def start @tomatoes -= 1 @stop_at = Time.now + tomato_time end |
#status ⇒ Object
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 |