class File::Visitor::Filter::Name
Public Class Methods
new(exp)
click to toggle source
# File lib/file/visitor/filter/name.rb, line 6 def initialize(exp) unless exp.is_a?(String) || exp.is_a?(Regexp) raise ArgumentError, "expression must be String or Regexp" end @exp = exp end
Public Instance Methods
match?(path)
click to toggle source
# File lib/file/visitor/filter/name.rb, line 13 def match?(path) filename = File.basename(path) return @exp == filename if @exp.is_a?(String) return filename =~ @exp if @exp.is_a?(Regexp) raise RuntimeError, "unexpected exp type: #{@exp.class}" end
to_s()
click to toggle source
# File lib/file/visitor/filter/name.rb, line 20 def to_s "%s[%s:%s]" % [self.class.name, @exp.class.name, @exp.to_s] end