Skip to content

Instantly share code, notes, and snippets.

@jamster
Created July 20, 2009 15:37
Show Gist options
  • Select an option

  • Save jamster/150403 to your computer and use it in GitHub Desktop.

Select an option

Save jamster/150403 to your computer and use it in GitHub Desktop.
def pph(hash, depth=0, output="")
if hash.is_a?(Hash)
carriage_return = depth > 0 ? "\n" : ""
output << carriage_return
hash.each do |key, val|
output << "\t" * depth + "#{key}\t=>\t#{pph(val, depth+1)}"
end
elsif hash.is_a?(Array)
return "["+hash.join(", ")+"]" +"\n"
else
return hash.to_s+"\n"
end
if depth > 0
return output
else
puts output
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment