Class: Filesortd::Matcher

Inherits:
Struct
  • Object
show all
Defined in:
lib/filesortd/matcher.rb

Overview

Basic matcher

Direct Known Subclasses

BasenameMatcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#patternObject

Returns the value of attribute pattern

Returns:

  • (Object)

    the current value of pattern



5
6
7
# File 'lib/filesortd/matcher.rb', line 5

def pattern
  @pattern
end

Instance Method Details

#match(s) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/filesortd/matcher.rb', line 6

def match(s)
  if pattern.is_a? Regexp
    !pattern.match(s).nil? # return a boolean through "not nil"
  elsif pattern.is_a? String
    File.fnmatch(pattern, s)
  end
end