Class: Cadre::Libnotify::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/cadre/libnotify/notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Notifier

Returns a new instance of Notifier.

Yields:

  • (_self)

Yield Parameters:



6
7
8
# File 'lib/cadre/libnotify/notifier.rb', line 6

def initialize
  yield self if block_given?
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



10
11
12
# File 'lib/cadre/libnotify/notifier.rb', line 10

def app_name
  @app_name
end

#expire_timeObject

Returns the value of attribute expire_time.



10
11
12
# File 'lib/cadre/libnotify/notifier.rb', line 10

def expire_time
  @expire_time
end

#messageObject

Returns the value of attribute message.



10
11
12
# File 'lib/cadre/libnotify/notifier.rb', line 10

def message
  @message
end

#soundObject

Returns the value of attribute sound.



10
11
12
# File 'lib/cadre/libnotify/notifier.rb', line 10

def sound
  @sound
end

#summaryObject

Returns the value of attribute summary.



10
11
12
# File 'lib/cadre/libnotify/notifier.rb', line 10

def summary
  @summary
end

#transientObject

Returns the value of attribute transient.



10
11
12
# File 'lib/cadre/libnotify/notifier.rb', line 10

def transient
  @transient
end

Instance Method Details

#goObject



12
13
14
15
16
# File 'lib/cadre/libnotify/notifier.rb', line 12

def go
  cmd = "notify-send #{options} \"#@summary\" \"#@message\""
  %x[#{cmd}]
  %x[paplay #{Valise.find(["sounds", sound]).full_path}] if String === sound
end

#optionsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cadre/libnotify/notifier.rb', line 18

def options
  options = []
  unless expire_time.nil?
    options << "-t #@expire_time"
  end

  if transient
    options << "-h \"byte:transient:1\""
  end

  unless app_name.nil?
    options << "-a #@app_name"
  end

  options.join(" ")
end