Class: RegexpExamples::BackReferenceGroup
- Inherits:
-
Object
- Object
- RegexpExamples::BackReferenceGroup
- Includes:
- RandomResultBySample
- Defined in:
- lib/regexp-examples/groups.rb
Overview
This is a bit magic… We substitute backreferences with PLACEHOLDERS. These are then, later, replaced by the appropriate value. (See BackReferenceReplacer) The simplest example is /(a) 1/ - So, we temporarily treat the “result” of /1/ as being “1”. It later gets updated.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(id) ⇒ BackReferenceGroup
constructor
A new instance of BackReferenceGroup.
- #result ⇒ Object
Methods included from RandomResultBySample
Methods included from ForceLazyEnumerators
Constructor Details
#initialize(id) ⇒ BackReferenceGroup
Returns a new instance of BackReferenceGroup.
207 208 209 |
# File 'lib/regexp-examples/groups.rb', line 207 def initialize(id) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
206 207 208 |
# File 'lib/regexp-examples/groups.rb', line 206 def id @id end |
Instance Method Details
#result ⇒ Object
211 212 213 |
# File 'lib/regexp-examples/groups.rb', line 211 def result [GroupResult.new("__#{@id}__")] end |