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.



76
77
78
# File 'lib/json/stream/builder.rb', line 76

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

Instance Attribute Details

#objObject (readonly)

Returns the value of attribute obj.



74
75
76
# File 'lib/json/stream/builder.rb', line 74

def obj
  @obj
end

Instance Method Details

#<<(node) ⇒ Object



80
81
82
83
84
85
86
87
88
# File 'lib/json/stream/builder.rb', line 80

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