Class: SyntaxTree::GVar
Overview
GVar represents a global variable literal.
$variable
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- String
-
the name of the global variable.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ GVar
constructor
A new instance of GVar.
Methods inherited from Node
Constructor Details
#initialize(value:, location:, comments: []) ⇒ GVar
Returns a new instance of GVar.
4233 4234 4235 4236 4237 |
# File 'lib/syntax_tree/node.rb', line 4233 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
4231 4232 4233 |
# File 'lib/syntax_tree/node.rb', line 4231 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the name of the global variable
4228 4229 4230 |
# File 'lib/syntax_tree/node.rb', line 4228 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
4239 4240 4241 |
# File 'lib/syntax_tree/node.rb', line 4239 def accept(visitor) visitor.visit_gvar(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
4243 4244 4245 |
# File 'lib/syntax_tree/node.rb', line 4243 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
4249 4250 4251 |
# File 'lib/syntax_tree/node.rb', line 4249 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
4253 4254 4255 |
# File 'lib/syntax_tree/node.rb', line 4253 def format(q) q.text(value) end |