Class: Notifiers::NotifySend

Inherits:
Base
  • Object
show all
Defined in:
lib/notifiers/notify_send.rb

Constant Summary collapse

COMMAND =
'notify-send'

Instance Method Summary collapse

Methods inherited from Base

command?, darwin?, #image, inherited, #install_instructions, installed?, #message, #notify, platform?, subclasses, #title

Instance Method Details

#expire_time(time) ⇒ Object



10
11
12
13
# File 'lib/notifiers/notify_send.rb', line 10

def expire_time(time)
  @expire_time = time
  self
end

#hint(values) ⇒ Object



15
16
17
18
# File 'lib/notifiers/notify_send.rb', line 15

def hint(values)
  @hint = values.collect.each { |element| element.to_s}.join(':')
  self
end

#to_sObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/notifiers/notify_send.rb', line 20

def to_s
  command = COMMAND.clone
  [:hint, :priority, :icon, :urgency].each do |option|
    variable = instance_variable_get("@#{option}")
    command << " --#{option}=#{variable}" if variable
  end
  command << " --expire-time=#{@expire_time}" if @expire_time
  [:title, :message].each do |option|
    variable = instance_variable_get("@#{option}")
    command << " '#{variable}'" if variable
  end
  command
end

#urgency(level) ⇒ Object



5
6
7
8
# File 'lib/notifiers/notify_send.rb', line 5

def urgency(level)
  @urgency = level.to_s
  self
end