Class: SyntaxTree::MRHS
- Inherits:
-
Object
- Object
- SyntaxTree::MRHS
- Defined in:
- lib/syntax_tree.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
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#parts ⇒ Object
readonly
Array the parts that are being assigned.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(parts:, location:, comments: []) ⇒ MRHS
constructor
A new instance of MRHS.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(parts:, location:, comments: []) ⇒ MRHS
Returns a new instance of MRHS.
8643 8644 8645 8646 8647 |
# File 'lib/syntax_tree.rb', line 8643 def initialize(parts:, location:, comments: []) @parts = parts @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8641 8642 8643 |
# File 'lib/syntax_tree.rb', line 8641 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
8638 8639 8640 |
# File 'lib/syntax_tree.rb', line 8638 def location @location end |
#parts ⇒ Object (readonly)
Array the parts that are being assigned
8635 8636 8637 |
# File 'lib/syntax_tree.rb', line 8635 def parts @parts end |
Instance Method Details
#child_nodes ⇒ Object
8649 8650 8651 |
# File 'lib/syntax_tree.rb', line 8649 def child_nodes parts end |
#format(q) ⇒ Object
8653 8654 8655 |
# File 'lib/syntax_tree.rb', line 8653 def format(q) q.seplist(parts) { |part| q.format(part) } end |
#pretty_print(q) ⇒ Object
8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 |
# File 'lib/syntax_tree.rb', line 8657 def pretty_print(q) q.group(2, "(", ")") do q.text("mrhs") q.breakable q.group(2, "(", ")") { q.seplist(parts) { |part| q.pp(part) } } q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
8668 8669 8670 8671 8672 |
# File 'lib/syntax_tree.rb', line 8668 def to_json(*opts) { type: :mrhs, parts: parts, loc: location, cmts: comments }.to_json( *opts ) end |