Class: Coyote::Notifier

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

Class Method Summary collapse

Class Method Details

.color(message, color) ⇒ Object



25
26
27
# File 'lib/coyote/notifier.rb', line 25

def self.color(message, color)
  message.send(color)
end

.colorsObject



29
30
31
32
33
# File 'lib/coyote/notifier.rb', line 29

def self.colors
  {:success => :green,
   :warning => :yellow,
   :failure => :red }
end

.notify(message, options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/coyote/notifier.rb', line 5

def self.notify(message, options)
  message = String(message)
  
  if options.include? :timestamp
    message = timestamp message
  end

  options.each do |option|
    if colors.has_key? option
      message = color(message, colors[option])
    end
  end

  puts message
end

.timestamp(message) ⇒ Object



21
22
23
# File 'lib/coyote/notifier.rb', line 21

def self.timestamp(message)
  "#{Time.new.strftime("%I:%M:%S")}      #{message}"
end