class Hoss::Config::WildcardPatternList::WildcardPattern

@api private

Public Class Methods

new(str) click to toggle source
# File lib/hoss/config/wildcard_pattern_list.rb, line 26
def initialize(str)
  @pattern = convert(str)
end

Public Instance Methods

match(other)
Alias for: match?
match?(other) click to toggle source
# File lib/hoss/config/wildcard_pattern_list.rb, line 30
def match?(other)
  !!@pattern.match(other)
end
Also aliased as: match

Private Instance Methods

convert(str) click to toggle source
# File lib/hoss/config/wildcard_pattern_list.rb, line 38
def convert(str)
  parts =
    str.chars.each_with_object([]) do |char, arr|
      arr << (char == '*' ? '.*' : Regexp.escape(char))
    end

  Regexp.new('\A' + parts.join + '\Z', Regexp::IGNORECASE)
end