class ElasticAPM::Config::WildcardPatternList::WildcardPattern
@api private
Attributes
pattern[R]
Public Class Methods
new(str)
click to toggle source
# File lib/elastic_apm/config/wildcard_pattern_list.rb, line 26 def initialize(str) @pattern = convert(str) end
Public Instance Methods
match?(other)
click to toggle source
# File lib/elastic_apm/config/wildcard_pattern_list.rb, line 32 def match?(other) !!@pattern.match(other) end
Also aliased as: match
Private Instance Methods
convert(str)
click to toggle source
# File lib/elastic_apm/config/wildcard_pattern_list.rb, line 40 def convert(str) case_sensitive = false if str.start_with?('(?-i)') str = str.gsub(/^\(\?-\i\)/, '') case_sensitive = true end parts = str.chars.each_with_object([]) do |char, arr| arr << (char == '*' ? '.*' : Regexp.escape(char)) end Regexp.new( '\A' + parts.join + '\Z', case_sensitive ? nil : Regexp::IGNORECASE ) end