diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-14 11:39:21 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-14 11:39:21 +0000 |
commit | e76eb06feb024828034379797129d92522e28516 (patch) | |
tree | 1326c625c233ba2554043203a7697f5e3d4c49e5 /ruby_1_9_3/ext/psych/lib/psych/coder.rb | |
parent | aa6e98139c8e1ea442fb2182341aaa08ff55b529 (diff) | |
parent | bede15ac5e701ed08f3fc64c2dba03d3f393c652 (diff) |
add tag v1_9_3_426v1_9_3_426
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_3_426@40737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_9_3/ext/psych/lib/psych/coder.rb')
-rw-r--r-- | ruby_1_9_3/ext/psych/lib/psych/coder.rb | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/ruby_1_9_3/ext/psych/lib/psych/coder.rb b/ruby_1_9_3/ext/psych/lib/psych/coder.rb deleted file mode 100644 index 2b830d2b21..0000000000 --- a/ruby_1_9_3/ext/psych/lib/psych/coder.rb +++ /dev/null @@ -1,94 +0,0 @@ -module Psych - ### - # If an object defines +encode_with+, then an instance of Psych::Coder will - # be passed to the method when the object is being serialized. The Coder - # automatically assumes a Psych::Nodes::Mapping is being emitted. Other - # objects like Sequence and Scalar may be emitted if +seq=+ or +scalar=+ are - # called, respectively. - class Coder - attr_accessor :tag, :style, :implicit, :object - attr_reader :type, :seq - - def initialize tag - @map = {} - @seq = [] - @implicit = false - @type = :map - @tag = tag - @style = Psych::Nodes::Mapping::BLOCK - @scalar = nil - @object = nil - end - - def scalar *args - if args.length > 0 - warn "#{caller[0]}: Coder#scalar(a,b,c) is deprecated" if $VERBOSE - @tag, @scalar, _ = args - @type = :scalar - end - @scalar - 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 - self.scalar = value - end - - # Emit a sequence with +list+ and +tag+ - def represent_seq tag, list - @tag = tag - self.seq = list - end - - # Emit a sequence with +map+ and +tag+ - def represent_map tag, map - @tag = tag - self.map = map - end - - # Emit an arbitrary object +obj+ and +tag+ - def represent_object tag, obj - @tag = tag - @type = :object - @object = obj - end - - # Emit a scalar with +value+ - def scalar= value - @type = :scalar - @scalar = value - end - - # Emit a map with +value+ - def map= map - @type = :map - @map = map - end - - def []= k, v - @type = :map - @map[k] = v - end - alias :add :[]= - - def [] k - @type = :map - @map[k] - end - - # Emit a sequence of +list+ - def seq= list - @type = :seq - @seq = list - end - end -end |