module Remenv::Formatter

Public Instance Methods

pretty(hash) click to toggle source
# File lib/remenv/formatter.rb, line 5
def pretty(hash)
  hash  ||= {}
  max_len = hash.keys.map(&:size).max
  sorted  = hash.sort_by { |key, _| key }

  sorted.inject('') do |buff, (key, val)|
    buff << "#{key.to_s.ljust(max_len)} #{val}\n"
  end
end