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.
1220 1221 1222 1223 1224 |
# File 'lib/syntax_tree/node.rb', line 1220 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
1218 1219 1220 |
# File 'lib/syntax_tree/node.rb', line 1218 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the name of the global backreference variable
1215 1216 1217 |
# File 'lib/syntax_tree/node.rb', line 1215 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
1226 1227 1228 |
# File 'lib/syntax_tree/node.rb', line 1226 def accept(visitor) visitor.visit_backref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1230 1231 1232 |
# File 'lib/syntax_tree/node.rb', line 1230 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
1236 1237 1238 |
# File 'lib/syntax_tree/node.rb', line 1236 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
1240 1241 1242 |
# File 'lib/syntax_tree/node.rb', line 1240 def format(q) q.text(value) end |