Class: RegexpExamples::CharGroup

Inherits:
Object
  • Object
show all
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

#ignorecase

Instance Method Summary collapse

Methods included from RandomResultBySample

#random_result

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

#resultObject



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