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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(left:, right:, location:, comments: []) ⇒ VarAlias
Returns a new instance of VarAlias.
9286 9287 9288 9289 9290 9291 |
# File 'lib/syntax_tree/node.rb', line 9286 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
9284 9285 9286 |
# File 'lib/syntax_tree/node.rb', line 9284 def comments @comments end |
#left ⇒ Object (readonly)
- GVar
-
the new alias of the variable
9278 9279 9280 |
# File 'lib/syntax_tree/node.rb', line 9278 def left @left end |
#right ⇒ Object (readonly)
- Backref | GVar
-
the current name of the variable to be aliased
9281 9282 9283 |
# File 'lib/syntax_tree/node.rb', line 9281 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
9293 9294 9295 |
# File 'lib/syntax_tree/node.rb', line 9293 def accept(visitor) visitor.visit_var_alias(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9297 9298 9299 |
# File 'lib/syntax_tree/node.rb', line 9297 def child_nodes [left, right] end |
#deconstruct_keys(_keys) ⇒ Object
9303 9304 9305 |
# File 'lib/syntax_tree/node.rb', line 9303 def deconstruct_keys(_keys) { left: left, right: right, location: location, comments: comments } end |
#format(q) ⇒ Object
9307 9308 9309 9310 9311 9312 9313 9314 |
# File 'lib/syntax_tree/node.rb', line 9307 def format(q) keyword = "alias " q.text(keyword) q.format(left) q.text(" ") q.format(right) end |