Class: FileGlob

Inherits:
Object
  • Object
show all
Defined in:
lib/file_glob.rb

Defined Under Namespace

Classes: GlobMatchData

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ FileGlob

Returns a new instance of FileGlob.



4
5
6
# File 'lib/file_glob.rb', line 4

def initialize(pattern)
  @pattern = pattern
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern.



2
3
4
# File 'lib/file_glob.rb', line 2

def pattern
  @pattern
end

Instance Method Details

#===(path) ⇒ Object



12
13
14
# File 'lib/file_glob.rb', line 12

def === path
  File.fnmatch?(pattern, path)
end

#=~(path) ⇒ Object



8
9
10
# File 'lib/file_glob.rb', line 8

def =~ path
  0 if File.fnmatch?(pattern, path)
end

#inspectObject



24
25
26
# File 'lib/file_glob.rb', line 24

def inspect
  "<#FileGlob #{pattern}>"
end

#match(path) ⇒ Object



16
17
18
# File 'lib/file_glob.rb', line 16

def match(path)
  GlobMatchData.new(path) if self =~ path
end

#to_sObject



20
21
22
# File 'lib/file_glob.rb', line 20

def to_s
  pattern
end