Class: RegexpExamples::CharGroup
- Inherits:
-
Object
- Object
- RegexpExamples::CharGroup
- Includes:
- GroupWithIgnoreCase, RandomResultBySample
- Defined in:
- lib/regexp-examples/groups.rb
Overview
The most generic type of group, which contains 0 or more characters. Technically, this is the ONLY type of group that is truly necessary However, having others both improves performance through various optimisations, and clarifies the code’s intention. The most common example of CharGroups is: /[abc]/
Instance Attribute Summary
Attributes included from GroupWithIgnoreCase
Instance Method Summary collapse
-
#initialize(chars, ignorecase) ⇒ CharGroup
constructor
A new instance of CharGroup.
- #result ⇒ Object
Methods included from RandomResultBySample
Methods included from ForceLazyEnumerators
Constructor Details
#initialize(chars, ignorecase) ⇒ CharGroup
Returns a new instance of CharGroup.
95 96 97 98 |
# File 'lib/regexp-examples/groups.rb', line 95 def initialize(chars, ignorecase) @chars = chars @ignorecase = ignorecase end |
Instance Method Details
#result ⇒ Object
100 101 102 103 104 |
# File 'lib/regexp-examples/groups.rb', line 100 def result @chars.lazy.map do |result| GroupResult.new(result) end end |