Posted By

eugegim on 01/12/09


Tagged

textmate serialization yaml


Versions (?)

Yaml Serialization Example


 / Published in: Other
 

  1. require "yaml"
  2.  
  3. class Hello
  4. attr_reader :monkey
  5. def hoho
  6. @monkey = "bob"
  7. end
  8. end
  9.  
  10. a = Hello.new
  11. a.hoho
  12.  
  13. puts a.to_yaml.inspect
  14.  
  15. b = Hello.new
  16.  
  17. puts b.to_yaml.inspect
  18.  
  19. aa = "--- !ruby/object:Hello nmonkey: bobn"
  20. bb = "--- !ruby/object:Hello {}nn"
  21.  
  22. aaa = YAML::load(aa)
  23. bbb = YAML::load(bb)
  24.  
  25. puts aaa.inspect
  26. puts bbb.inspect
  27.  
  28. puts aaa.monkey
  29. puts bbb.monkey

Report this snippet  

You need to login to post a comment.