Class: JSON::Stream::ObjectNode

Inherits:
Object
  • Object
show all
Defined in:
lib/json/stream/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeObjectNode

Returns a new instance of ObjectNode.



86
87
88
# File 'lib/json/stream/builder.rb', line 86

def initialize
  @obj, @key = {}, nil
end

Instance Attribute Details

#objObject (readonly)

Returns the value of attribute obj.



84
85
86
# File 'lib/json/stream/builder.rb', line 84

def obj
  @obj
end

Instance Method Details

#<<(node) ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/json/stream/builder.rb', line 90

def <<(node)
  if @key
    @obj[@key] = node
    @key = nil
  else
    @key = node 
  end
  self
end

#to_sObject



100
101
102
# File 'lib/json/stream/builder.rb', line 100

def to_s
  "OBJ Node: {#{@key.inspect}: #{@obj.inspect}}"
end