Module: EacRubyUtils::Console::Speaker

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

Overview

Defined Under Namespace

Classes: List

Instance Method Summary collapse

Instance Method Details

#fatal_error(string) ⇒ Object



20
21
22
23
# File 'lib/eac_ruby_utils/console/speaker.rb', line 20

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

#info(string) ⇒ Object



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

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

#infom(string) ⇒ Object



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

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

#infov(*args) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/eac_ruby_utils/console/speaker.rb', line 58

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



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

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

#puts(string = '') ⇒ Object



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

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

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



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/eac_ruby_utils/console/speaker.rb', line 45

def request_input(question, options = {})
  options = ::EacRubyUtils::OptionsConsumer.new(options)
  bool, list, noecho = options.consume_all(:bool, :list, :noecho)
  options.validate
  if list
    request_from_list(question, list, noecho)
  elsif bool
    request_from_bool(question, noecho)
  else
    request_string(question, noecho)
  end
end

#success(string) ⇒ Object



70
71
72
# File 'lib/eac_ruby_utils/console/speaker.rb', line 70

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

#title(string) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/eac_ruby_utils/console/speaker.rb', line 25

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



41
42
43
# File 'lib/eac_ruby_utils/console/speaker.rb', line 41

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