Class: CycleRunner
- Inherits:
-
Object
- Object
- CycleRunner
- Defined in:
- lib/core/cycle_runner.rb
Instance Method Summary collapse
-
#initialize(cycles, pomodoro_time, pause_time, break_time) ⇒ CycleRunner
constructor
A new instance of CycleRunner.
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(cycles, pomodoro_time, pause_time, break_time) ⇒ CycleRunner
Returns a new instance of CycleRunner.
3 4 5 6 7 8 |
# File 'lib/core/cycle_runner.rb', line 3 def initialize cycles, pomodoro_time, pause_time, break_time @timer_pomodoro = Timer.new pomodoro_time @timer_pause = Timer.new pause_time @timer_break = Timer.new break_time @cycles = cycles end |
Instance Method Details
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/core/cycle_runner.rb', line 10 def run @thread = Thread.new do begin @cycles.times do |i| Window.instance.pop_up @timer_pomodoro.run if i + 1 != @cycles Window.instance.panel..label = "Time for a litle pause..." Window.instance.pop_up @timer_pause.run end end Window.instance.panel..label = "Now it's time to rest..." Window.instance.pop_up @timer_break.run rescue => e puts e Thread.stop end Window.instance.pop_up Window.instance.panel..enable end end |