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.
7759
7760
7761
7762
7763
|
# File 'lib/syntax_tree/node.rb', line 7759
def initialize(parts:, location:)
@parts = parts
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7757
7758
7759
|
# File 'lib/syntax_tree/node.rb', line 7757
def
@comments
end
|
#parts ⇒ Object
Array the parts that are being assigned
7754
7755
7756
|
# File 'lib/syntax_tree/node.rb', line 7754
def parts
@parts
end
|
Instance Method Details
#===(other) ⇒ Object
7794
7795
7796
|
# File 'lib/syntax_tree/node.rb', line 7794
def ===(other)
other.is_a?(MRHS) && ArrayMatch.call(parts, other.parts)
end
|
#accept(visitor) ⇒ Object
7765
7766
7767
|
# File 'lib/syntax_tree/node.rb', line 7765
def accept(visitor)
visitor.visit_mrhs(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
7769
7770
7771
|
# File 'lib/syntax_tree/node.rb', line 7769
def child_nodes
parts
end
|
#copy(parts: nil, location: nil) ⇒ Object
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
|
# File 'lib/syntax_tree/node.rb', line 7773
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
7786
7787
7788
|
# File 'lib/syntax_tree/node.rb', line 7786
def deconstruct_keys(_keys)
{ parts: parts, location: location, comments: }
end
|
7790
7791
7792
|
# File 'lib/syntax_tree/node.rb', line 7790
def format(q)
q.seplist(parts) { |part| q.format(part) }
end
|