/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
require "yaml" class Hello attr_reader :monkey def hoho @monkey = "bob" end end a = Hello.new a.hoho puts a.to_yaml.inspect b = Hello.new puts b.to_yaml.inspect aa = "--- !ruby/object:Hello nmonkey: bobn" bb = "--- !ruby/object:Hello {}nn" aaa = YAML::load(aa) bbb = YAML::load(bb) puts aaa.inspect puts bbb.inspect puts aaa.monkey puts bbb.monkey