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
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Backref
Returns a new instance of Backref.
1268 1269 1270 1271 1272 |
# File 'lib/syntax_tree/node.rb', line 1268 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
1266 1267 1268 |
# File 'lib/syntax_tree/node.rb', line 1266 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the name of the global backreference variable
1263 1264 1265 |
# File 'lib/syntax_tree/node.rb', line 1263 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
1274 1275 1276 |
# File 'lib/syntax_tree/node.rb', line 1274 def accept(visitor) visitor.visit_backref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1278 1279 1280 |
# File 'lib/syntax_tree/node.rb', line 1278 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
1284 1285 1286 |
# File 'lib/syntax_tree/node.rb', line 1284 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
1288 1289 1290 |
# File 'lib/syntax_tree/node.rb', line 1288 def format(q) q.text(value) end |