Module: AiCli::Helpers::StripRegexPatterns

Defined in:
lib/aicli/helpers/strip_regex_patterns.rb

Class Method Summary collapse

Class Method Details

.call(input_string, pattern_list) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/aicli/helpers/strip_regex_patterns.rb', line 8

def call(input_string, pattern_list)
  pattern_list.reduce(input_string) do |current, pattern|
    next current if pattern.nil?

    if pattern.is_a?(Regexp)
      current.gsub(pattern, '')
    else
      current.gsub(pattern.to_s, '')
    end
  end
end