summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych/coder.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-31 17:56:55 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-31 17:56:55 +0000
commit69c6ee0b45ad7e850dd0665c0f25d82602c49326 (patch)
tree022101b496ca6267c8db00d699a2449369e0de02 /ext/psych/lib/psych/coder.rb
parent6024074540e3ea0e50f764900f94d2c641a3c1cc (diff)
* ext/psych/lib/psych/coder.rb: Adding Syck compatibility to the yaml coder
* test/psych/test_coder.rb: test for syck compatibility git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/lib/psych/coder.rb')
-rw-r--r--ext/psych/lib/psych/coder.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/psych/lib/psych/coder.rb b/ext/psych/lib/psych/coder.rb
index 79e46dab1b..eff0cc3dcb 100644
--- a/ext/psych/lib/psych/coder.rb
+++ b/ext/psych/lib/psych/coder.rb
@@ -7,7 +7,7 @@ module Psych
# called, respectively.
class Coder
attr_accessor :tag, :style, :implicit
- attr_reader :type, :map, :scalar, :seq
+ attr_reader :type, :scalar, :seq
def initialize tag
@map = {}
@@ -19,6 +19,14 @@ module Psych
@scalar = nil
end
+ # Emit a map. The coder will be yielded to the block.
+ def map tag = @tag, style = @style
+ @tag = tag
+ @style = style
+ yield self if block_given?
+ @map
+ end
+
# Emit a scalar with +value+ and +tag+
def represent_scalar tag, value
self.tag = tag
@@ -53,6 +61,7 @@ module Psych
@type = :map
@map[k] = v
end
+ alias :add :[]=
def [] k
@type = :map