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.



80
81
82
# File 'lib/json/stream/builder.rb', line 80

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

Instance Attribute Details

#objObject (readonly)

Returns the value of attribute obj.



78
79
80
# File 'lib/json/stream/builder.rb', line 78

def obj
  @obj
end

Instance Method Details

#<<(node) ⇒ Object



84
85
86
87
88
89
90
91
92
# File 'lib/json/stream/builder.rb', line 84

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

#to_sObject



94
95
96
# File 'lib/json/stream/builder.rb', line 94

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