11 11, 2004
YAML ºÍ Ruby
# file name zhu.rb
require 'yaml'
class Person
attr_accessor :name, :sex, :age, :email
def initialize
@name="liubin"
@sex="male"
@age=25
@email="liubin at huangpuzhuang.com"
end
def doSomthing
puts " do somthing "
end
end
person=Person.new()
puts (person.to_yaml)
C:>ruby zhu.rb
--- !ruby/object:Person
age: 25
email: liubin at huangpuzhuang.com
name: liubin
sex: male
C:>
×îлظ´