Class: SyntaxTree::PinnedVarRef
Overview
PinnedVarRef represents a pinned variable reference within a pattern matching pattern.
case value
in ^variable
end
This can be a plain local variable like the example above. It can also be a a class variable, a global variable, or an instance variable.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- VarRef
-
the value of this node.
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: []) ⇒ PinnedVarRef
constructor
A new instance of PinnedVarRef.
Methods inherited from Node
Constructor Details
#initialize(value:, location:, comments: []) ⇒ PinnedVarRef
Returns a new instance of PinnedVarRef.
9303 9304 9305 9306 9307 |
# File 'lib/syntax_tree/node.rb', line 9303 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
9301 9302 9303 |
# File 'lib/syntax_tree/node.rb', line 9301 def comments @comments end |
#value ⇒ Object (readonly)
- VarRef
-
the value of this node
9298 9299 9300 |
# File 'lib/syntax_tree/node.rb', line 9298 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
9309 9310 9311 |
# File 'lib/syntax_tree/node.rb', line 9309 def accept(visitor) visitor.visit_pinned_var_ref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9313 9314 9315 |
# File 'lib/syntax_tree/node.rb', line 9313 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
9319 9320 9321 |
# File 'lib/syntax_tree/node.rb', line 9319 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
9323 9324 9325 9326 9327 9328 |
# File 'lib/syntax_tree/node.rb', line 9323 def format(q) q.group do q.text("^") q.format(value) end end |