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.



6352
6353
6354
6355
6356
# File 'lib/syntax_tree/node.rb', line 6352

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



6350
6351
6352
# File 'lib/syntax_tree/node.rb', line 6350

def comments
  @comments
end

#partsObject (readonly)

Array the parts that are being assigned



6347
6348
6349
# File 'lib/syntax_tree/node.rb', line 6347

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



6358
6359
6360
# File 'lib/syntax_tree/node.rb', line 6358

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

#child_nodesObject Also known as: deconstruct



6362
6363
6364
# File 'lib/syntax_tree/node.rb', line 6362

def child_nodes
  parts
end

#deconstruct_keys(_keys) ⇒ Object



6368
6369
6370
# File 'lib/syntax_tree/node.rb', line 6368

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

#format(q) ⇒ Object



6372
6373
6374
# File 'lib/syntax_tree/node.rb', line 6372

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