Class: Ruby::Pomodoro::NotificationObserver

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

Instance Method Summary collapse

Constructor Details

#initialize(stop:, pause:, time:, printer: Printer.new) ⇒ NotificationObserver

Returns a new instance of NotificationObserver.

Parameters:



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

Parameters:

  • event (Symbol)


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