Guest User

Untitled

a guest
May 27th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1.  
  2. def dump(obj, label = "", indent=0)
  3. if obj.class.respond_to? :keys
  4. obj.class.keys.each do |key|
  5. dump(obj.send(key), key, indent+1)
  6. end
  7. elsif obj.respond_to? :each
  8. obj.each do |o|
  9. # This would work, except the stack level goes too deep :-(
  10. #dump(o, " - ", indent+1)
  11. end
  12. else
  13. print " " * indent, label, ": "
  14. puts obj.inspect
  15. end
  16. end
Add Comment
Please, Sign In to add comment