Module: EacRubyUtils::Console::Speaker
- Included in:
- Envs::Command
- Defined in:
- lib/eac_ruby_utils/console/speaker.rb
Overview
Instance Method Summary collapse
- #fatal_error(string) ⇒ Object
- #info(string) ⇒ Object
- #infov(*args) ⇒ Object
- #out(string = '') ⇒ Object
- #puts(string = '') ⇒ Object
- #success(string) ⇒ Object
- #title(string) ⇒ Object
- #warn(string) ⇒ Object
Instance Method Details
#fatal_error(string) ⇒ Object
15 16 17 18 |
# File 'lib/eac_ruby_utils/console/speaker.rb', line 15 def fatal_error(string) puts "ERROR: #{string}".white.on_red Kernel.exit 1 end |
#info(string) ⇒ Object
27 28 29 |
# File 'lib/eac_ruby_utils/console/speaker.rb', line 27 def info(string) puts string.white end |
#infov(*args) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/eac_ruby_utils/console/speaker.rb', line 35 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
11 12 13 |
# File 'lib/eac_ruby_utils/console/speaker.rb', line 11 def out(string = '') STDOUT.write(string) end |
#puts(string = '') ⇒ Object
7 8 9 |
# File 'lib/eac_ruby_utils/console/speaker.rb', line 7 def puts(string = '') STDERR.puts(string) # rubocop:disable Style/StderrPuts end |
#success(string) ⇒ Object
47 48 49 |
# File 'lib/eac_ruby_utils/console/speaker.rb', line 47 def success(string) puts string.green end |
#title(string) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/eac_ruby_utils/console/speaker.rb', line 20 def title(string) puts(('-' * (8 + string.length)).green) puts("--- #{string} ---".green) puts(('-' * (8 + string.length)).green) puts end |
#warn(string) ⇒ Object
31 32 33 |
# File 'lib/eac_ruby_utils/console/speaker.rb', line 31 def warn(string) puts string.yellow end |