Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > yamlライブラリ > Objectクラス > to_yaml_properties
to_yaml_properties -> [String] [added by yaml]
Object#instance_variables.sortの結果を返します。
require 'yaml'
h = {
:ugo => 17,
:hoge => "fuga",
}
p h.to_yaml_properties
#=> []
class MyDog
attr_accessor :name, :age
end
c = MyDog.new
c.name = "Pochi"
c.age = 3
p c.to_yaml_properties.join(",")
#=> ["@age,@name"]