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


112
113
114
115
# File 'app/api/core/io/json/grammar.rb', line 112

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


110
111
112
# File 'app/api/core/io/json/grammar.rb', line 110

def name
  @name
end

Instance Method Details

#call(object, options, stream) ⇒ Object


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

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

#dupObject


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

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

#inspectObject


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

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

#merge(node) ⇒ Object


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

def merge(node)
  super(node) { |children| self.class.new(@name, children) }
end