Class: Notifiers::Base

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

Direct Known Subclasses

Growl, Knotify, NotifySend

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.command?(command) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/notifiers/base.rb', line 25

def self.command?(command)
  `which #{command}` and $?.to_i.zero?
end

.darwin?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/notifiers/base.rb', line 17

def self.darwin?
  platform?(/darwin/)
end

.inherited(subclass) ⇒ Object



3
4
5
6
7
# File 'lib/notifiers/base.rb', line 3

def self.inherited(subclass)
  @subclasses ||= []
  @subclasses.push(subclass)
  @subclasses
end

.installed?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/notifiers/base.rb', line 13

def self.installed?
  false
end

.platform?(name) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/notifiers/base.rb', line 21

def self.platform?(name)
  RbConfig::CONFIG['host_os'] =~ name or RUBY_PLATFORM =~ name
end

.subclassesObject



9
10
11
# File 'lib/notifiers/base.rb', line 9

def self.subclasses
  @subclasses
end

Instance Method Details

#image(icon) ⇒ Object



48
49
50
51
# File 'lib/notifiers/base.rb', line 48

def image(icon)
  @icon = icon
  self
end

#install_instructionsObject



53
54
55
# File 'lib/notifiers/base.rb', line 53

def install_instructions
  ''
end

#message(text) ⇒ Object



38
39
40
41
# File 'lib/notifiers/base.rb', line 38

def message(text)
  @message = text
  self
end

#notifyObject Also known as: notify!



29
30
31
32
33
34
35
# File 'lib/notifiers/base.rb', line 29

def notify
  notification = system(to_s)

  puts install_instructions unless notification or install_instructions.empty?

  notification
end

#title(text) ⇒ Object



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

def title(text)
  @title = text
  self
end