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, #pretty_print, #to_json
Constructor Details
#initialize(parts:, location:) ⇒ MRHS
Returns a new instance of MRHS.
7771
7772
7773
7774
7775
|
# File 'lib/syntax_tree/node.rb', line 7771
def initialize(parts:, location:)
@parts = parts
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7769
7770
7771
|
# File 'lib/syntax_tree/node.rb', line 7769
def
end
|
#parts ⇒ Object
Array the parts that are being assigned
7766
7767
7768
|
# File 'lib/syntax_tree/node.rb', line 7766
def parts
@parts
end
|
Instance Method Details
#===(other) ⇒ Object
7806
7807
7808
|
# File 'lib/syntax_tree/node.rb', line 7806
def ===(other)
other.is_a?(MRHS) && ArrayMatch.call(parts, other.parts)
end
|
#accept(visitor) ⇒ Object
7777
7778
7779
|
# File 'lib/syntax_tree/node.rb', line 7777
def accept(visitor)
visitor.visit_mrhs(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
7781
7782
7783
|
# File 'lib/syntax_tree/node.rb', line 7781
def child_nodes
parts
end
|
#copy(parts: nil, location: nil) ⇒ Object
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
|
# File 'lib/syntax_tree/node.rb', line 7785
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
7798
7799
7800
|
# File 'lib/syntax_tree/node.rb', line 7798
def deconstruct_keys(_keys)
{ parts: parts, location: location, comments: }
end
|
7802
7803
7804
|
# File 'lib/syntax_tree/node.rb', line 7802
def format(q)
q.seplist(parts) { |part| q.format(part) }
end
|