Class: FileGlob
- Inherits:
-
Object
- Object
- FileGlob
- Defined in:
- lib/file_glob.rb
Defined Under Namespace
Classes: GlobMatchData
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
- #===(path) ⇒ Object
- #=~(path) ⇒ Object
-
#initialize(pattern) ⇒ FileGlob
constructor
A new instance of FileGlob.
- #inspect ⇒ Object
- #match(path) ⇒ Object
- #to_s ⇒ Object
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
#pattern ⇒ Object (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 |
#inspect ⇒ Object
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_s ⇒ Object
20 21 22 |
# File 'lib/file_glob.rb', line 20 def to_s pattern end |