Class: SyntaxTree::MRHS
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::MRHS
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, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(parts:, location:) ⇒ MRHS
Returns a new instance of MRHS.
7892
7893
7894
7895
7896
|
# File 'lib/syntax_tree/node.rb', line 7892
def initialize(parts:, location:)
@parts = parts
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7890
7891
7892
|
# File 'lib/syntax_tree/node.rb', line 7890
def
@comments
end
|
#parts ⇒ Object
- Array
-
the parts that are being assigned
7887
7888
7889
|
# File 'lib/syntax_tree/node.rb', line 7887
def parts
@parts
end
|
Instance Method Details
#===(other) ⇒ Object
7927
7928
7929
|
# File 'lib/syntax_tree/node.rb', line 7927
def ===(other)
other.is_a?(MRHS) && ArrayMatch.call(parts, other.parts)
end
|
#accept(visitor) ⇒ Object
7898
7899
7900
|
# File 'lib/syntax_tree/node.rb', line 7898
def accept(visitor)
visitor.visit_mrhs(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
7902
7903
7904
|
# File 'lib/syntax_tree/node.rb', line 7902
def child_nodes
parts
end
|
#copy(parts: nil, location: nil) ⇒ Object
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
|
# File 'lib/syntax_tree/node.rb', line 7906
def copy(parts: nil, location: nil)
node =
MRHS.new(
parts: parts || self.parts,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
7919
7920
7921
|
# File 'lib/syntax_tree/node.rb', line 7919
def deconstruct_keys(_keys)
{ parts: parts, location: location, comments: }
end
|
7923
7924
7925
|
# File 'lib/syntax_tree/node.rb', line 7923
def format(q)
q.seplist(parts) { |part| q.format(part) }
end
|