Skip to content

Instantly share code, notes, and snippets.

@dotmh
Created June 10, 2012 06:05
Show Gist options
  • Save dotmh/2904078 to your computer and use it in GitHub Desktop.
Save dotmh/2904078 to your computer and use it in GitHub Desktop.
A ruby hash inspector
def inspect data , depth = 0
data.each do | key , value |
if value.class == Hash
spacing = ''
depth.times { spacing << '-' }
puts spacing+' '+key.to_s
inspect value , depth+1
else
spacing = ''
depth.times { spacing << '-' }
puts spacing+' '+key.to_s+': '+value.to_s
end
end
end
@dotmh
Copy link
Author

dotmh commented Jun 10, 2012

ok this isn't actual that useful as it can only inspect Hashes , I am writing a new one that is able to do more.

PS if I am been stupid and there is a nice way to output hashes natively in ruby then let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment