Class: SyntaxTree::CVar

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

CVar represents the use of a class variable.

@@variable

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:, comments: []) ⇒ CVar

Returns a new instance of CVar.



3403
3404
3405
3406
3407
# File 'lib/syntax_tree/node.rb', line 3403

def initialize(value:, location:, comments: [])
  @value = value
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



3401
3402
3403
# File 'lib/syntax_tree/node.rb', line 3401

def comments
  @comments
end

#valueObject (readonly)

String

the name of the class variable



3398
3399
3400
# File 'lib/syntax_tree/node.rb', line 3398

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



3409
3410
3411
# File 'lib/syntax_tree/node.rb', line 3409

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

#child_nodesObject Also known as: deconstruct



3413
3414
3415
# File 'lib/syntax_tree/node.rb', line 3413

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



3419
3420
3421
# File 'lib/syntax_tree/node.rb', line 3419

def deconstruct_keys(_keys)
  { value: value, location: location, comments: comments }
end

#format(q) ⇒ Object



3423
3424
3425
# File 'lib/syntax_tree/node.rb', line 3423

def format(q)
  q.text(value)
end