Class: Ruby::Pomodoro::Notification

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, channel) ⇒ Notification

Returns a new instance of Notification.

Parameters:

  • message (String)

    Message

  • channel (Object, Module)

    Channel to push message



8
9
10
11
# File 'lib/ruby/pomodoro/notification.rb', line 8

def initialize(message, channel)
  @message = message
  @channel = channel
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/ruby/pomodoro/notification.rb', line 4

def message
  @message
end

Instance Method Details

#notify(repeat_at = nil, skip_now: false) ⇒ TrueClass

Parameters:

  • repeat_at (Numeric) (defaults to: nil)

    Time to repeat

  • skip_now (Boolean) (defaults to: false)

    Skip notify after call, default: false

Returns:

  • (TrueClass)


16
17
18
19
20
# File 'lib/ruby/pomodoro/notification.rb', line 16

def notify(repeat_at = nil, skip_now: false)
  @channel.call(message) unless skip_now
  repeat(repeat_at) if repeat_at
  true
end

#stopTrueClass

Returns:

  • (TrueClass)


23
24
25
26
# File 'lib/ruby/pomodoro/notification.rb', line 23

def stop
  @thread&.kill
  true
end