Class: Notifiers::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/notifiers/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.command?(command) ⇒ Boolean
23
24
25
|
# File 'lib/notifiers/base.rb', line 23
def self.command?(command)
`which #{command}` and success_process_status?
end
|
.inherited(subclass) ⇒ Object
5
6
7
8
9
|
# File 'lib/notifiers/base.rb', line 5
def self.inherited(subclass)
@subclasses ||= []
@subclasses.push(subclass)
@subclasses
end
|
.installed? ⇒ Boolean
15
16
17
|
# File 'lib/notifiers/base.rb', line 15
def self.installed?
false
end
|
19
20
21
|
# File 'lib/notifiers/base.rb', line 19
def self.platform?(name)
RbConfig::CONFIG['host_os'] =~ name or RUBY_PLATFORM =~ name
end
|
.process?(process_name) ⇒ Boolean
27
28
29
|
# File 'lib/notifiers/base.rb', line 27
def self.process?(process_name)
`ps -A #{process_name}` and success_process_status?
end
|
.subclasses ⇒ Object
11
12
13
|
# File 'lib/notifiers/base.rb', line 11
def self.subclasses
@subclasses
end
|
.success_process_status? ⇒ Boolean
31
32
33
|
# File 'lib/notifiers/base.rb', line 31
def self.success_process_status?
$?.to_i.zero?
end
|
Instance Method Details
#image(icon) ⇒ Object
54
55
56
57
|
# File 'lib/notifiers/base.rb', line 54
def image(icon)
@icon = icon
self
end
|
#install_instructions ⇒ Object
59
60
61
|
# File 'lib/notifiers/base.rb', line 59
def install_instructions
''
end
|
#message(text) ⇒ Object
44
45
46
47
|
# File 'lib/notifiers/base.rb', line 44
def message(text)
@message = text
self
end
|
#notify ⇒ Object
Also known as:
notify!
35
36
37
38
39
40
41
|
# File 'lib/notifiers/base.rb', line 35
def notify
notification = system(to_s)
puts install_instructions unless notification or install_instructions.empty?
notification
end
|
#title(text) ⇒ Object
49
50
51
52
|
# File 'lib/notifiers/base.rb', line 49
def title(text)
@title = text
self
end
|