Class: Conveyor::Output::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/conveyor/output/console.rb

Class Method Summary collapse

Class Method Details

.error(*msg) ⇒ Object



36
37
38
39
40
41
# File 'lib/conveyor/output/console.rb', line 36

def error(*msg)
  options = msg.extract_options!
  options[:color] ||= :red
  msg.flatten!
  output(*msg, options)
end

.output(*msg) ⇒ Object Also known as: info, debug



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/conveyor/output/console.rb', line 11

def output(*msg)
  options = msg.extract_options!
  options[:color] ||= :default
  options[:tab] ||= 0

  format = "\t"*options[:tab]
  format << "\r[%s] %s"
  if msg.class == Array
    msg.each do |m|
      puts sprintf(format, Time.now, m).color(options[:color])              
    end
  else
    puts sprintf(format, Time.now, msg).color(options[:color])              
  end
end

.warning(*msg) ⇒ Object



29
30
31
32
33
34
# File 'lib/conveyor/output/console.rb', line 29

def warning(*msg)
  options = msg.extract_options!
  options[:color] ||= :yellow
  msg.flatten!
  output(*msg, options)
end

.write(msgtype, *msg) ⇒ Object



5
6
7
8
9
# File 'lib/conveyor/output/console.rb', line 5

def write(msgtype, *msg)
  if respond_to?(msgtype)
    self.send(msgtype, *msg)
  end
end