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.



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

def ignorecase
  @ignorecase
end

Instance Method Details

#resultObject



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

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