class Glob::Matcher

Attributes

path[R]
regex[R]

Public Class Methods

new(path) click to toggle source
# File lib/glob/matcher.rb, line 7
def initialize(path)
  @path = path
  @reject = path.start_with?("!")

  pattern = Regexp.escape(path.gsub(/^!/, "")).gsub(/\\\*/, "[^.]+")
  @regex = Regexp.new("^#{pattern}")
end

Public Instance Methods

include?() click to toggle source
# File lib/glob/matcher.rb, line 19
def include?
  !reject?
end
match?(other) click to toggle source
# File lib/glob/matcher.rb, line 15
def match?(other)
  other.match?(regex)
end
reject?() click to toggle source
# File lib/glob/matcher.rb, line 23
def reject?
  @reject
end