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
Constructor Details
#initialize(chars, ignorecase) ⇒ CharGroup
Returns a new instance of CharGroup.
86 87 88 89 |
# File 'lib/regexp-examples/groups.rb', line 86 def initialize(chars, ignorecase) @chars = chars @ignorecase = ignorecase end |
Instance Method Details
#result ⇒ Object
91 92 93 94 95 |
# File 'lib/regexp-examples/groups.rb', line 91 def result @chars.lazy.map do |result| GroupResult.new(result) end end |