Class: Kumi::Core::NAST::Pair

Inherits:
Node
  • Object
show all
Defined in:
lib/kumi/core/nast.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#id, #loc, #meta

Instance Method Summary collapse

Methods inherited from Node

#each_child

Constructor Details

#initialize(key:, value:, **k) ⇒ Pair

Returns a new instance of Pair.



146
147
148
149
150
# File 'lib/kumi/core/nast.rb', line 146

def initialize(key:, value:, **k)
  super(**k)
  @key = key
  @value = value
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



144
145
146
# File 'lib/kumi/core/nast.rb', line 144

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



144
145
146
# File 'lib/kumi/core/nast.rb', line 144

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



152
153
154
# File 'lib/kumi/core/nast.rb', line 152

def accept(visitor)
  visitor.visit_pair(self)
end

#childrenObject



156
# File 'lib/kumi/core/nast.rb', line 156

def children = [key, value].grep(Node)