class Psych::Coder
Wenn ein Objekt encode_with definiert, wird eine Instanz von Psych::Coder an die Methode übergeben, wenn das Objekt serialisiert wird. Der Coder nimmt automatisch an, dass ein Psych::Nodes::Mapping ausgegeben wird. Andere Objekte wie Sequenz und Skalar können ausgegeben werden, wenn seq= bzw. scalar= aufgerufen werden.
Attribute
Öffentliche Klassenmethoden
Source
# File ext/psych/lib/psych/coder.rb, line 13 def initialize tag @map = {} @seq = [] @implicit = false @type = :map @tag = tag @style = Psych::Nodes::Mapping::BLOCK @scalar = nil @object = nil end
Öffentliche Instanzmethoden
Source
# File ext/psych/lib/psych/coder.rb, line 78 def []= k, v @type = :map @map[k] = v end
Auch alias für: add
Source
# File ext/psych/lib/psych/coder.rb, line 34 def map tag = @tag, style = @style @tag = tag @style = style yield self if block_given? @map end
Eine Zuordnung ausgeben. Der Coder wird an den Block übergeben.
Source
# File ext/psych/lib/psych/coder.rb, line 73 def map= map @type = :map @map = map end
Eine Zuordnung mit value ausgeben
Source
# File ext/psych/lib/psych/coder.rb, line 54 def represent_map tag, map @tag = tag self.map = map end
Eine Sequenz mit map und tag ausgeben
Source
# File ext/psych/lib/psych/coder.rb, line 60 def represent_object tag, obj @tag = tag @type = :object @object = obj end
Ein beliebiges Objekt obj und tag ausgeben
Source
# File ext/psych/lib/psych/coder.rb, line 42 def represent_scalar tag, value self.tag = tag self.scalar = value end
Einen Skalar mit value und tag ausgeben
Source
# File ext/psych/lib/psych/coder.rb, line 48 def represent_seq tag, list @tag = tag self.seq = list end
Eine Sequenz mit list und tag ausgeben
Source
# File ext/psych/lib/psych/coder.rb, line 24 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
Source
# File ext/psych/lib/psych/coder.rb, line 67 def scalar= value @type = :scalar @scalar = value end
Einen Skalar mit value ausgeben
Source
# File ext/psych/lib/psych/coder.rb, line 90 def seq= list @type = :seq @seq = list end
Eine Sequenz von list ausgeben