Module: RegexpExamples::GroupWithIgnoreCase

Includes:
ForceLazyEnumerators
Included in:
CharGroup, SingleCharGroup
Defined in:
lib/regexp-examples/groups.rb

Overview

A helper method for mixing in to Group classes… Needed for generating a complete results set when the ignorecase regexp option has been set

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ForceLazyEnumerators

#force_if_lazy

Instance Attribute Details

#ignorecaseObject (readonly)

Returns the value of attribute ignorecase.



37
38
39
# File 'lib/regexp-examples/groups.rb', line 37

def ignorecase
  @ignorecase
end

Instance Method Details

#resultObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/regexp-examples/groups.rb', line 38

def result
  group_result = super
  if ignorecase
    group_result_array = force_if_lazy(group_result)
    group_result_array
      .concat(group_result_array.map(&:swapcase))
      .uniq
  else
    group_result
  end
end