Module: Azure::Helpers

Included in:
AzureInterface
Defined in:
lib/azure/helpers.rb

Instance Method Summary collapse

Instance Method Details

#display_list(ui = nil, columns = [], rows = []) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/azure/helpers.rb', line 30

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



38
39
40
41
42
# File 'lib/azure/helpers.rb', line 38

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



22
23
24
# File 'lib/azure/helpers.rb', line 22

def random_string(len=10)
  (0...len).map{65.+(rand(25)).chr}.join
end

#strip_non_ascii(string) ⇒ Object



26
27
28
# File 'lib/azure/helpers.rb', line 26

def strip_non_ascii(string)
  string.gsub(/[^0-9a-z ]/i, '')
end