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

#pretty_print, #to_json

Constructor Details

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

Returns a new instance of VCall.



8778
8779
8780
8781
8782
# File 'lib/syntax_tree/node.rb', line 8778

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



8776
8777
8778
# File 'lib/syntax_tree/node.rb', line 8776

def comments
  @comments
end

#valueObject (readonly)

Ident

the value of this expression



8773
8774
8775
# File 'lib/syntax_tree/node.rb', line 8773

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



8784
8785
8786
# File 'lib/syntax_tree/node.rb', line 8784

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

#child_nodesObject Also known as: deconstruct



8788
8789
8790
# File 'lib/syntax_tree/node.rb', line 8788

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object



8794
8795
8796
# File 'lib/syntax_tree/node.rb', line 8794

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

#format(q) ⇒ Object



8798
8799
8800
# File 'lib/syntax_tree/node.rb', line 8798

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