Class: Kumi::Core::NAST::Declaration

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(name:, body:, **k) ⇒ Declaration

Returns a new instance of Declaration.



230
231
232
233
234
# File 'lib/kumi/core/nast.rb', line 230

def initialize(name:, body:, **k)
  super(**k)
  @name = name.to_sym
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



228
229
230
# File 'lib/kumi/core/nast.rb', line 228

def body
  @body
end

#nameObject (readonly)

Returns the value of attribute name.



228
229
230
# File 'lib/kumi/core/nast.rb', line 228

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object



236
237
238
# File 'lib/kumi/core/nast.rb', line 236

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

#childrenObject



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

def children = [body]

#kindObject



242
243
244
# File 'lib/kumi/core/nast.rb', line 242

def kind
  meta[:kind]
end