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.



9343
9344
9345
9346
9347
# File 'lib/syntax_tree/node.rb', line 9343

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



9341
9342
9343
# File 'lib/syntax_tree/node.rb', line 9341

def comments
  @comments
end

#valueObject (readonly)

Ident

the value of this expression



9338
9339
9340
# File 'lib/syntax_tree/node.rb', line 9338

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



9349
9350
9351
# File 'lib/syntax_tree/node.rb', line 9349

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

#child_nodesObject Also known as: deconstruct



9353
9354
9355
# File 'lib/syntax_tree/node.rb', line 9353

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object



9359
9360
9361
# File 'lib/syntax_tree/node.rb', line 9359

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

#format(q) ⇒ Object



9363
9364
9365
# File 'lib/syntax_tree/node.rb', line 9363

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