Class: SyntaxTree::MRHS

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

Overview

MRHS represents the values that are being assigned on the right-hand side of a multiple assignment.

values = first, second, third

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(parts:, location:, comments: []) ⇒ MRHS

Returns a new instance of MRHS.



6463
6464
6465
6466
6467
# File 'lib/syntax_tree/node.rb', line 6463

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

Instance Attribute Details

#comments ⇒ Object (readonly)

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



6461
6462
6463
# File 'lib/syntax_tree/node.rb', line 6461

def comments
  @comments
end

#parts ⇒ Object (readonly)

Array the parts that are being assigned



6458
6459
6460
# File 'lib/syntax_tree/node.rb', line 6458

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



6469
6470
6471
# File 'lib/syntax_tree/node.rb', line 6469

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

#child_nodes ⇒ Object Also known as: deconstruct



6473
6474
6475
# File 'lib/syntax_tree/node.rb', line 6473

def child_nodes
  parts
end

#deconstruct_keys(_keys) ⇒ Object



6479
6480
6481
# File 'lib/syntax_tree/node.rb', line 6479

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

#format(q) ⇒ Object



6483
6484
6485
# File 'lib/syntax_tree/node.rb', line 6483

def format(q)
  q.seplist(parts) { |part| q.format(part) }
end