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.



6261
6262
6263
6264
6265
# File 'lib/syntax_tree/node.rb', line 6261

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



6259
6260
6261
# File 'lib/syntax_tree/node.rb', line 6259

def comments
  @comments
end

#partsObject (readonly)

Array the parts that are being assigned



6256
6257
6258
# File 'lib/syntax_tree/node.rb', line 6256

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



6267
6268
6269
# File 'lib/syntax_tree/node.rb', line 6267

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

#child_nodesObject Also known as: deconstruct



6271
6272
6273
# File 'lib/syntax_tree/node.rb', line 6271

def child_nodes
  parts
end

#deconstruct_keys(keys) ⇒ Object



6277
6278
6279
# File 'lib/syntax_tree/node.rb', line 6277

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

#format(q) ⇒ Object



6281
6282
6283
# File 'lib/syntax_tree/node.rb', line 6281

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