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.



9566
9567
9568
9569
9570
# File 'lib/syntax_tree/node.rb', line 9566

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

Instance Attribute Details

#comments ⇒ Object (readonly)

[Array[ Comment | EmbDoc ]] the comments attached to this node



9564
9565
9566
# File 'lib/syntax_tree/node.rb', line 9564

def comments
  @comments
end

#value ⇒ Object (readonly)

[Ident] the value of this expression



9561
9562
9563
# File 'lib/syntax_tree/node.rb', line 9561

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



9572
9573
9574
# File 'lib/syntax_tree/node.rb', line 9572

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

#child_nodes ⇒ Object Also known as: deconstruct



9576
9577
9578
# File 'lib/syntax_tree/node.rb', line 9576

def child_nodes
  [value]
end

#deconstruct_keys(_keys) ⇒ Object



9582
9583
9584
# File 'lib/syntax_tree/node.rb', line 9582

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

#format(q) ⇒ Object



9586
9587
9588
# File 'lib/syntax_tree/node.rb', line 9586

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