Class: PomodoroTimer::Pomodoro
- Inherits:
-
Object
- Object
- PomodoroTimer::Pomodoro
- Defined in:
- lib/pomodoro_timer/pomodoro.rb
Instance Attribute Summary collapse
-
#running ⇒ Object
readonly
Returns the value of attribute running.
Instance Method Summary collapse
- #cancel ⇒ Object
- #finished? ⇒ Boolean
-
#initialize(will_work = false) ⇒ Pomodoro
constructor
A new instance of Pomodoro.
- #show_status ⇒ Object
Constructor Details
#initialize(will_work = false) ⇒ Pomodoro
Returns a new instance of Pomodoro.
5 6 7 8 |
# File 'lib/pomodoro_timer/pomodoro.rb', line 5 def initialize(will_work=false) @running = RunningThread.new(will_work) return nil end |
Instance Attribute Details
#running ⇒ Object (readonly)
Returns the value of attribute running.
3 4 5 |
# File 'lib/pomodoro_timer/pomodoro.rb', line 3 def running @running end |
Instance Method Details
#cancel ⇒ Object
21 22 23 |
# File 'lib/pomodoro_timer/pomodoro.rb', line 21 def cancel @running.kill end |
#finished? ⇒ Boolean
25 26 27 |
# File 'lib/pomodoro_timer/pomodoro.rb', line 25 def finished? return @running.cycle.stopped? end |
#show_status ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pomodoro_timer/pomodoro.rb', line 10 def show_status cycle = @running.cycle if cycle.stopped? puts "No pomodoro running." elsif cycle.break? puts "It's break time! (#{format_seconds(cycle.missing_progress)})" else puts "It's work time! (#{format_seconds(cycle.missing_progress)})" end end |