Module: Azure::Helpers
- Included in:
- AzureInterface
- Defined in:
- lib/azure/helpers.rb
Instance Method Summary collapse
- #display_list(ui = nil, columns = [], rows = []) ⇒ Object
- #msg_pair(ui = nil, label = nil, value = nil, color = :cyan) ⇒ Object
- #random_string(len = 10) ⇒ Object
- #strip_non_ascii(string) ⇒ Object
Instance Method Details
#display_list(ui = nil, columns = [], rows = []) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/azure/helpers.rb', line 29 def display_list(ui = nil, columns = [], rows = []) columns = columns.map { |col| ui.color(col, :bold) } count = columns.count rows = columns.concat(rows) puts "" puts ui.list(rows, :uneven_columns_across, count) end |
#msg_pair(ui = nil, label = nil, value = nil, color = :cyan) ⇒ Object
37 38 39 40 41 |
# File 'lib/azure/helpers.rb', line 37 def msg_pair(ui = nil, label = nil, value = nil, color = :cyan) if value && !value.to_s.empty? puts "#{ui.color(label, color)}: #{value}" end end |
#random_string(len = 10) ⇒ Object
21 22 23 |
# File 'lib/azure/helpers.rb', line 21 def random_string(len = 10) (0...len).map { 65.+(rand(25)).chr }.join end |
#strip_non_ascii(string) ⇒ Object
25 26 27 |
# File 'lib/azure/helpers.rb', line 25 def strip_non_ascii(string) string.gsub(/[^0-9a-z ]/i, "") end |