Class: Core::Io::Json::Grammar::Node

Inherits:
Object
  • Object
show all
Includes:
Intermediate
Defined in:
app/api/core/io/json/grammar.rb

Instance Attribute Summary collapse

Attributes included from Intermediate

#children

Instance Method Summary collapse

Methods included from Intermediate

#[], #leaf, #merge_children_with

Constructor Details

#initialize(name, children = nil) ⇒ Node

Returns a new instance of Node.



119
120
121
122
# File 'app/api/core/io/json/grammar.rb', line 119

def initialize(name, children = nil)
  super(children)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



117
118
119
# File 'app/api/core/io/json/grammar.rb', line 117

def name
  @name
end

Instance Method Details

#call(object, options, stream) ⇒ Object



124
125
126
# File 'app/api/core/io/json/grammar.rb', line 124

def call(object, options, stream)
  stream.block(@name) { |stream| super(object, options, stream) }
end

#dupObject



128
129
130
# File 'app/api/core/io/json/grammar.rb', line 128

def dup
  duplicate { |children| self.class.new(@name, children) }
end

#inspectObject



138
139
140
# File 'app/api/core/io/json/grammar.rb', line 138

def inspect
  "Node<#{@name},#{super}>"
end

#merge(node) ⇒ Object



132
133
134
135
136
# File 'app/api/core/io/json/grammar.rb', line 132

def merge(node)
  super(node) do |children|
    self.class.new(@name, children) # prettier-ignore
  end
end