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.
9173 9174 9175 9176 9177 9178 |
# File 'lib/syntax_tree/node.rb', line 9173 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
9171 9172 9173 |
# File 'lib/syntax_tree/node.rb', line 9171 def comments @comments end |
#left ⇒ Object (readonly)
- GVar
-
the new alias of the variable
9165 9166 9167 |
# File 'lib/syntax_tree/node.rb', line 9165 def left @left end |
#right ⇒ Object (readonly)
- Backref | GVar
-
the current name of the variable to be aliased
9168 9169 9170 |
# File 'lib/syntax_tree/node.rb', line 9168 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
9180 9181 9182 |
# File 'lib/syntax_tree/node.rb', line 9180 def accept(visitor) visitor.visit_var_alias(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9184 9185 9186 |
# File 'lib/syntax_tree/node.rb', line 9184 def child_nodes [left, right] end |
#deconstruct_keys(keys) ⇒ Object
9190 9191 9192 |
# File 'lib/syntax_tree/node.rb', line 9190 def deconstruct_keys(keys) { left: left, right: right, location: location, comments: comments } end |
#format(q) ⇒ Object
9194 9195 9196 9197 9198 9199 9200 9201 |
# File 'lib/syntax_tree/node.rb', line 9194 def format(q) keyword = "alias " q.text(keyword) q.format(left) q.text(" ") q.format(right) end |