Class: SyntaxTree::VCall

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

Overview

VCall represent any plain named object with Ruby that could be either a local variable or a method call.

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: []) ⇒ VCall

Returns a new instance of VCall.



9455
9456
9457
9458
9459
# File 'lib/syntax_tree/node.rb', line 9455

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



9453
9454
9455
# File 'lib/syntax_tree/node.rb', line 9453

def comments
  @comments
end

#valueObject (readonly)

Ident

the value of this expression



9450
9451
9452
# File 'lib/syntax_tree/node.rb', line 9450

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



9461
9462
9463
# File 'lib/syntax_tree/node.rb', line 9461

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

#child_nodesObject Also known as: deconstruct



9465
9466
9467
# File 'lib/syntax_tree/node.rb', line 9465

def child_nodes
  [value]
end

#deconstruct_keys(_keys) ⇒ Object



9471
9472
9473
# File 'lib/syntax_tree/node.rb', line 9471

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

#format(q) ⇒ Object



9475
9476
9477
# File 'lib/syntax_tree/node.rb', line 9475

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