Ruby 1.8.7 Reference Manual > All Libraries > library yaml/rubytypes > class Struct > to_yaml

instance method Struct#to_yaml

to_yaml(opts = {}) [added by yaml/rubytypes]

自身を YAML ドキュメントに変換します。

[PARAM] opts:
YAML ドキュメント出力の際のオプションを指定します。 オプションの詳細は YAML::Syck::Emitter#reset を参照し てください。
Foo = Struct.new(:bar, :baz)
print Foo.new("bar", "baz").to_yaml
# => --- !ruby/struct:Foo
bar: bar
baz: baz