Module: Notifier

Extended by:
Notifier
Included in:
Notifier
Defined in:
lib/notifier.rb,
lib/notifier/growl.rb,
lib/notifier/snarl.rb,
lib/notifier/kdialog.rb,
lib/notifier/knotify.rb,
lib/notifier/osd_cat.rb,
lib/notifier/placebo.rb,
lib/notifier/version.rb,
lib/notifier/notify_send.rb

Defined Under Namespace

Modules: Growl, Kdialog, Knotify, NotifySend, OsdCat, Placebo, Snarl, Version

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.default_notifierObject

Returns the value of attribute default_notifier.



16
17
18
# File 'lib/notifier.rb', line 16

def default_notifier
  @default_notifier
end

Instance Method Details

#from_name(name) ⇒ Object



37
38
39
40
41
# File 'lib/notifier.rb', line 37

def from_name(name)
  notifier = const_get(classify(name.to_s))
rescue Exception
  nil
end

#notifierObject



19
20
21
# File 'lib/notifier.rb', line 19

def notifier
  supported_notifier_from_name(default_notifier) || supported_notifiers.first
end

#notifiersObject



27
28
29
30
31
# File 'lib/notifier.rb', line 27

def notifiers
  constants.collect do |name|
    const_get(name) unless %w[Placebo Version].include?(name.to_s)
  end.compact + [Placebo]
end

#notify(options) ⇒ Object



23
24
25
# File 'lib/notifier.rb', line 23

def notify(options)
  notifier.notify(options)
end

#supported_notifier_from_name(name) ⇒ Object



43
44
45
46
# File 'lib/notifier.rb', line 43

def supported_notifier_from_name(name)
  notifier = from_name(name)
  notifier && notifier.supported? ? notifier : nil
end

#supported_notifiersObject



33
34
35
# File 'lib/notifier.rb', line 33

def supported_notifiers
  notifiers.select {|notifier| notifier.supported?}
end