Class: SyntaxTree::Backref
Overview
Backref represents a global variable referencing a matched value. It comes in the form of a $ followed by a positive integer.
$1
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 backreference 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: []) ⇒ Backref
constructor
A new instance of Backref.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Backref
Returns a new instance of Backref.
1337 1338 1339 1340 1341 |
# File 'lib/syntax_tree/node.rb', line 1337 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
1335 1336 1337 |
# File 'lib/syntax_tree/node.rb', line 1335 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the name of the global backreference variable
1332 1333 1334 |
# File 'lib/syntax_tree/node.rb', line 1332 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
1343 1344 1345 |
# File 'lib/syntax_tree/node.rb', line 1343 def accept(visitor) visitor.visit_backref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1347 1348 1349 |
# File 'lib/syntax_tree/node.rb', line 1347 def child_nodes [] end |
#deconstruct_keys(_keys) ⇒ Object
1353 1354 1355 |
# File 'lib/syntax_tree/node.rb', line 1353 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
1357 1358 1359 |
# File 'lib/syntax_tree/node.rb', line 1357 def format(q) q.text(value) end |