Class: PrettyConsoleOutput::Console

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Console

Returns a new instance of Console.



7
8
9
10
11
12
13
14
# File 'lib/pretty_console_output.rb', line 7

def initialize(options={})
  options[:theme]  = {} if options[:theme].nil?
  options[:stdout] = $stdout if options[:stdout].nil?

  @color  = Color.new(options[:stdout])
  @theme  = Theme.new(options[:theme])
  @stdout = options[:stdout]
end

Instance Method Details

#data(obj) ⇒ Object



32
33
34
35
36
# File 'lib/pretty_console_output.rb', line 32

def data(obj)
  string = obj.to_s

  puts @color.colorize("     #{string}".gsub(/\n/, "\n     "), @theme.log_color)
end

#done(obj) ⇒ Object



44
45
46
47
48
# File 'lib/pretty_console_output.rb', line 44

def done(obj)
  string = obj.to_s

  puts @color.colorize("#{string}", @theme.done_color)
end

#error(obj) ⇒ Object



38
39
40
41
42
# File 'lib/pretty_console_output.rb', line 38

def error(obj)
  string = obj.to_s

  puts @color.colorize("#{string}", @theme.error_color)
end

#info(obj) ⇒ Object



20
21
22
23
24
# File 'lib/pretty_console_output.rb', line 20

def info(obj)
  string = obj.to_s

  puts @color.colorize("#{string}", @theme.info_color)
end

#log(obj) ⇒ Object



26
27
28
29
30
# File 'lib/pretty_console_output.rb', line 26

def log(obj)
  string = obj.to_s

  puts @color.colorize("     #{string}", @theme.log_color)
end

#puts(obj) ⇒ Object



16
17
18
# File 'lib/pretty_console_output.rb', line 16

def puts(obj)
  @stdout.puts obj
end

#tag(obj) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/pretty_console_output.rb', line 50

def tag(obj)
  start_tag_time

  time   = @color.colorize(elapsed_time_tag, @theme.tag_date_color)
  string = @color.colorize(obj, @theme.tag_text_color, bold: @theme.tag_bold, underscore: @theme.tag_underscore)

  puts "\n#{time} #{string}\n\n"
end