Class: RiotNotifier::RedgreenBinary

Inherits:
Base
  • Object
show all
Defined in:
lib/riot_notifier/redgreen_binary.rb

Constant Summary collapse

PATH =
ENV['HOME'] + "/bin/notify_redgreen"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#error, #fail, inherited, #results

Constructor Details

#initialize(path = PATH) ⇒ RedgreenBinary

Returns a new instance of RedgreenBinary.



8
9
10
11
# File 'lib/riot_notifier/redgreen_binary.rb', line 8

def initialize(path = PATH)
  super()
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/riot_notifier/redgreen_binary.rb', line 5

def path
  @path
end

Class Method Details

.usable?Boolean

Returns:

  • (Boolean)


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

def self.usable?
  File.exist?(PATH)
end

Instance Method Details

#exec(*args) ⇒ Object



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

def exec(*args)
  Kernel.system(*args)
end

#notify(color, msg) ⇒ Object



13
14
15
16
17
# File 'lib/riot_notifier/redgreen_binary.rb', line 13

def notify(color, msg)
  msg.gsub!(/</, '&lt;')
  msg.gsub!(/"/, "\\\"")
  exec "#{@path} #{color} \"#{msg}\""
end