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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:, comments: []) ⇒ PinnedVarRef
Returns a new instance of PinnedVarRef.
9492 9493 9494 9495 9496 |
# File 'lib/syntax_tree/node.rb', line 9492 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
9490 9491 9492 |
# File 'lib/syntax_tree/node.rb', line 9490 def comments @comments end |
#value ⇒ Object (readonly)
- VarRef
-
the value of this node
9487 9488 9489 |
# File 'lib/syntax_tree/node.rb', line 9487 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
9498 9499 9500 |
# File 'lib/syntax_tree/node.rb', line 9498 def accept(visitor) visitor.visit_pinned_var_ref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9502 9503 9504 |
# File 'lib/syntax_tree/node.rb', line 9502 def child_nodes [value] end |
#deconstruct_keys(_keys) ⇒ Object
9508 9509 9510 |
# File 'lib/syntax_tree/node.rb', line 9508 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
9512 9513 9514 9515 9516 9517 |
# File 'lib/syntax_tree/node.rb', line 9512 def format(q) q.group do q.text("^") q.format(value) end end |