Created
July 20, 2009 15:37
-
-
Save jamster/150403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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