summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych/nodes
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-31 21:09:58 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-31 21:09:58 +0000
commita4dbc2ea1020a0a393a0134cc900397a895a88e7 (patch)
tree93d9e2fd0f71104982884e31ea661d7d8d9504bd /ext/psych/lib/psych/nodes
parentc97f5f514a63f2b5ed909aec270e89efb0c2703d (diff)
* ext/psych/lib/psych.rb: Syck api compatibility [ruby-core:29157]
* ext/psych/lib/psych/nodes/node.rb: ditto * test/psych/test_psych.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/lib/psych/nodes')
-rw-r--r--ext/psych/lib/psych/nodes/node.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/psych/lib/psych/nodes/node.rb b/ext/psych/lib/psych/nodes/node.rb
index 0de768c7ac..3ab9acae43 100644
--- a/ext/psych/lib/psych/nodes/node.rb
+++ b/ext/psych/lib/psych/nodes/node.rb
@@ -30,10 +30,12 @@ module Psych
# Convert this node to YAML.
#
# See also Psych::Visitors::Emitter
- def to_yaml
- io = StringIO.new
- Visitors::Emitter.new(io).accept self
- io.string
+ def to_yaml io = nil
+ real_io = io || StringIO.new
+
+ Visitors::Emitter.new(real_io).accept self
+ return real_io.string unless io
+ io
end
end
end