Class: SyntaxTree::VarAlias
Overview
VarAlias represents when you’re using the alias keyword with global variable arguments.
alias $new $old
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#left ⇒ Object
readonly
- GVar
-
the new alias of the variable.
-
#right ⇒ Object
readonly
- Backref | GVar
-
the current name of the variable to be aliased.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(left:, right:, location:, comments: []) ⇒ VarAlias
constructor
A new instance of VarAlias.
Methods inherited from Node
Constructor Details
#initialize(left:, right:, location:, comments: []) ⇒ VarAlias
Returns a new instance of VarAlias.
8613 8614 8615 8616 8617 8618 |
# File 'lib/syntax_tree/node.rb', line 8613 def initialize(left:, right:, location:, comments: []) @left = left @right = right @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8611 8612 8613 |
# File 'lib/syntax_tree/node.rb', line 8611 def comments @comments end |
#left ⇒ Object (readonly)
- GVar
-
the new alias of the variable
8605 8606 8607 |
# File 'lib/syntax_tree/node.rb', line 8605 def left @left end |
#right ⇒ Object (readonly)
- Backref | GVar
-
the current name of the variable to be aliased
8608 8609 8610 |
# File 'lib/syntax_tree/node.rb', line 8608 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
8620 8621 8622 |
# File 'lib/syntax_tree/node.rb', line 8620 def accept(visitor) visitor.visit_var_alias(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8624 8625 8626 |
# File 'lib/syntax_tree/node.rb', line 8624 def child_nodes [left, right] end |
#deconstruct_keys(keys) ⇒ Object
8630 8631 8632 |
# File 'lib/syntax_tree/node.rb', line 8630 def deconstruct_keys(keys) { left: left, right: right, location: location, comments: comments } end |
#format(q) ⇒ Object
8634 8635 8636 8637 8638 8639 8640 8641 |
# File 'lib/syntax_tree/node.rb', line 8634 def format(q) keyword = "alias " q.text(keyword) q.format(left) q.text(" ") q.format(right) end |