Class: EacCli::Speaker
- Inherits:
-
Object
show all
- Includes:
- EacRubyUtils::Speaker::Receiver
- Defined in:
- lib/eac_cli/speaker.rb,
lib/eac_cli/speaker/list.rb,
lib/eac_cli/speaker/options.rb,
lib/eac_cli/speaker/constants.rb,
lib/eac_cli/speaker/input_blocked.rb,
lib/eac_cli/speaker/input_requested.rb,
lib/eac_cli/speaker/request_from_list.rb
Defined Under Namespace
Modules: Constants, Options
Classes: InputBlocked, InputRequested, List, RequestFromList
Instance Method Summary
collapse
Instance Method Details
#error(string) ⇒ Object
26
27
28
|
# File 'lib/eac_cli/speaker.rb', line 26
def error(string)
puts "ERROR: #{string}".white.on_red
end
|
#info(string) ⇒ Object
38
39
40
|
# File 'lib/eac_cli/speaker.rb', line 38
def info(string)
puts string.to_s.white
end
|
#infom(string) ⇒ Object
42
43
44
|
# File 'lib/eac_cli/speaker.rb', line 42
def infom(string)
puts string.to_s.light_yellow
end
|
#infov(*args) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/eac_cli/speaker.rb', line 66
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
|
Options:
+bool+ ([Boolean], default: +false+): requires a answer "yes" or "no".
+list+ ([Hash] or [Array], default: +nil+): requires a answer from a list.
+noecho+ ([Boolean], default: +false+): does not output answer.
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/eac_cli/speaker.rb', line 54
def input(question, options = {})
bool, list, noecho, ignore_case =
options.to_options_consumer.consume_all(:bool, :list, :noecho, :ignore_case)
if list
request_from_list(question, list, noecho, ignore_case)
elsif bool
request_from_bool(question, noecho)
else
request_string(question, noecho)
end
end
|
#out(string = '') ⇒ Object
22
23
24
|
# File 'lib/eac_cli/speaker.rb', line 22
def out(string = '')
out_out.write(string.to_s)
end
|
#puts(string = '') ⇒ Object
16
17
18
19
20
|
# File 'lib/eac_cli/speaker.rb', line 16
def puts(string = '')
string.to_s.each_line do |line|
err_out.puts(err_line_prefix.to_s + line)
end
end
|
#success(string) ⇒ Object
78
79
80
|
# File 'lib/eac_cli/speaker.rb', line 78
def success(string)
puts string.to_s.green
end
|
#title(string) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/eac_cli/speaker.rb', line 30
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
46
47
48
|
# File 'lib/eac_cli/speaker.rb', line 46
def warn(string)
puts string.to_s.yellow
end
|