Ruby 的 YAML 简单示例

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

require 'yaml'

class Person
  attr_accessor :name, :age
end

fred = Person.new
fred.name = "Fred Bloggs"
fred.age = 45

laura = Person.new
laura.name = "Laura Smith"
laura.age = 23

test_data = [ fred, laura ]

puts YAML::dump(test_data)