class Guard::Watcher::Pattern::Matcher

Attributes

matcher[R]

Public Class Methods

new(obj) click to toggle source
# File lib/guard/watcher/pattern/matcher.rb, line 7
def initialize(obj)
  @matcher = obj
end

Public Instance Methods

==(other) click to toggle source

Compare with other matcher @param other [Guard::Watcher::Pattern::Matcher]

other matcher for comparing

@return [true, false] equal or not

# File lib/guard/watcher/pattern/matcher.rb, line 15
def ==(other)
  matcher == other.matcher
end
match(string_or_pathname) click to toggle source
# File lib/guard/watcher/pattern/matcher.rb, line 19
def match(string_or_pathname)
  @matcher.match(normalized(string_or_pathname))
end

Private Instance Methods

normalized(string_or_pathname) click to toggle source
# File lib/guard/watcher/pattern/matcher.rb, line 25
def normalized(string_or_pathname)
  path = Pathname.new(string_or_pathname).cleanpath
  return path.to_s if @matcher.is_a?(Regexp)
  path
end