class Hash

Public Instance Methods

largest_key() click to toggle source
# File lib/bad_ass_extensions/hash.rb, line 3
def largest_key
  rows =[]
  keys.each_with_index do |f, i|
    rows << [f.to_s.length, i]
  end
  index = rows.sort_by{|x| x[0]}.last[1]
  keys[index]
end
rowized() click to toggle source
# File lib/bad_ass_extensions/hash.rb, line 12
def rowized
  max_key_length = largest_key.to_s.length
  keys.map do |key|
    "#{key.to_s.rjust(max_key_length)}: #{self[key]}\n"
  end
end