Method: WavefrontDisplay::Base#key_width

Defined in:
lib/wavefront-cli/display/base.rb

#key_width(hash = {}, pad = 2) ⇒ Integer

Give it a key-value hash, and it will return the size of the first column to use when formatting that data.

Parameters:

  • hash (Hash) (defaults to: {})

    the data for which you need a column width

  • pad (Integer) (defaults to: 2)

    the number of spaces you want between columns

Returns:

  • (Integer)

    length of longest key + pad



116
117
118
119
# File 'lib/wavefront-cli/display/base.rb', line 116

def key_width(hash = {}, pad = 2)
  return 0 if hash.keys.empty?
  hash.keys.map(&:size).max + pad
end