Module: Printing
- Defined in:
- lib/mixins/printing.rb
Overview
Binaries helper moduel
Instance Method Summary collapse
-
#are_you_sure?(msg) ⇒ Boolean
Ask for response.
-
#print_msg(msg_array) ⇒ Object
print_msg Params msg_array - Array of strings Usage: msg = [“hello”, “world”] print_msg(msg).
Instance Method Details
#are_you_sure?(msg) ⇒ Boolean
Ask for response
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mixins/printing.rb', line 21 def are_you_sure?(msg) puts msg resp = STDIN.gets.chomp case resp when "Y" when "yes" when "y" return true else return false end end |
#print_msg(msg_array) ⇒ Object
print_msg Params
msg_array - Array of strings
Usage:
msg = ["hello", "world"]
print_msg(msg)
11 12 13 14 15 16 17 18 |
# File 'lib/mixins/printing.rb', line 11 def print_msg(msg_array) arr = msg_array.map {|line| Colors.process(line) } max_size = arr.sort {|a,b| a.size <=> b.size }.last.size arr.each do |line| puts line.ljust(max_size) end Colors.reset! end |