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

#pretty_print, #to_json

Constructor Details

#initialize(parts:, location:, comments: []) ⇒ MRHS

Returns a new instance of MRHS.



5719
5720
5721
5722
5723
# File 'lib/syntax_tree/node.rb', line 5719

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



5717
5718
5719
# File 'lib/syntax_tree/node.rb', line 5717

def comments
  @comments
end

#partsObject (readonly)

Array the parts that are being assigned



5714
5715
5716
# File 'lib/syntax_tree/node.rb', line 5714

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



5725
5726
5727
# File 'lib/syntax_tree/node.rb', line 5725

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

#child_nodesObject Also known as: deconstruct



5729
5730
5731
# File 'lib/syntax_tree/node.rb', line 5729

def child_nodes
  parts
end

#deconstruct_keys(keys) ⇒ Object



5735
5736
5737
# File 'lib/syntax_tree/node.rb', line 5735

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

#format(q) ⇒ Object



5739
5740
5741
# File 'lib/syntax_tree/node.rb', line 5739

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