Class: Hash
Instance Method Summary collapse
Instance Method Details
#largest_key ⇒ Object
3 4 5 6 7 8 9 10 |
# 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 ⇒ Object
12 13 14 15 16 17 |
# 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 |