Module: EacRubyUtils::Console::Speaker

Included in:
Configs, Envs::Command
Defined in:
lib/eac_ruby_utils/console/speaker.rb

Overview

Instance Method Summary collapse

Instance Method Details

#fatal_error(string) ⇒ Object



17
18
19
20
# File 'lib/eac_ruby_utils/console/speaker.rb', line 17

def fatal_error(string)
  puts "ERROR: #{string}".white.on_red
  Kernel.exit 1
end

#info(string) ⇒ Object



30
31
32
# File 'lib/eac_ruby_utils/console/speaker.rb', line 30

def info(string)
  puts string.to_s.white
end

#infom(string) ⇒ Object



34
35
36
# File 'lib/eac_ruby_utils/console/speaker.rb', line 34

def infom(string)
  puts string.to_s.light_yellow
end

#infov(*args) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/eac_ruby_utils/console/speaker.rb', line 53

def infov(*args)
  r = []
  args.each_with_index do |v, i|
    if i.even?
      r << "#{v}: ".cyan
    else
      r.last << v.to_s
    end
  end
  puts r.join(', ')
end

#out(string = '') ⇒ Object



13
14
15
# File 'lib/eac_ruby_utils/console/speaker.rb', line 13

def out(string = '')
  STDOUT.write(string.to_s)
end

#puts(string = '') ⇒ Object



9
10
11
# File 'lib/eac_ruby_utils/console/speaker.rb', line 9

def puts(string = '')
  STDERR.puts(string.to_s)
end

#request_input(question, options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/eac_ruby_utils/console/speaker.rb', line 42

def request_input(question, options = {})
  STDERR.write "#{question}: ".to_s.yellow
  if options[:noecho]
    r = STDIN.noecho(&:gets).chomp.strip
    STDERR.write("\n")
    r
  else
    gets.chomp.strip
  end
end

#success(string) ⇒ Object



65
66
67
# File 'lib/eac_ruby_utils/console/speaker.rb', line 65

def success(string)
  puts string.to_s.green
end

#title(string) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/eac_ruby_utils/console/speaker.rb', line 22

def title(string)
  string = string.to_s
  puts(('-' * (8 + string.length)).green)
  puts("--- #{string} ---".green)
  puts(('-' * (8 + string.length)).green)
  puts
end

#warn(string) ⇒ Object



38
39
40
# File 'lib/eac_ruby_utils/console/speaker.rb', line 38

def warn(string)
  puts string.to_s.yellow
end