Class: Ruby::Pomodoro::NotificationObserver
- Inherits:
-
Object
- Object
- Ruby::Pomodoro::NotificationObserver
- Defined in:
- lib/ruby/pomodoro/notification_observer.rb
Instance Method Summary collapse
-
#initialize(stop:, pause:, time:, printer: Printer.new) ⇒ NotificationObserver
constructor
A new instance of NotificationObserver.
- #update(event) ⇒ Object
Constructor Details
#initialize(stop:, pause:, time:, printer: Printer.new) ⇒ NotificationObserver
Returns a new instance of NotificationObserver.
7 8 9 10 11 12 |
# File 'lib/ruby/pomodoro/notification_observer.rb', line 7 def initialize(stop:, pause:, time:, printer: Printer.new) @stop_notification = stop @pause_notification = pause @time = time @printer = printer end |
Instance Method Details
#update(event) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ruby/pomodoro/notification_observer.rb', line 15 def update(event) case event when :finish @stop_notification.notify(@time) @printer.print_line "_Task #{Worker.instance.current_task.name} was stopped, type [\u21e7 + R] for resume\r", color: :red when :pause @pause_notification.notify(@time, skip_now: true) when :stop, :start @pause_notification.stop @stop_notification.stop else @pause_notification.stop end end |