Class: Goodcheck::Glob
- Inherits:
-
Object
- Object
- Goodcheck::Glob
- Defined in:
- lib/goodcheck/glob.rb
Constant Summary collapse
- FNM_FLAGS =
File::FNM_PATHNAME | File::FNM_EXTGLOB | File::FNM_DOTMATCH
Instance Attribute Summary collapse
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
-
#exclude ⇒ Object
readonly
Returns the value of attribute exclude.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(pattern:, encoding:, exclude:) ⇒ Glob
constructor
A new instance of Glob.
- #test(path) ⇒ Object
Constructor Details
#initialize(pattern:, encoding:, exclude:) ⇒ Glob
Returns a new instance of Glob.
9 10 11 12 13 |
# File 'lib/goodcheck/glob.rb', line 9 def initialize(pattern:, encoding:, exclude:) @pattern = pattern @encoding = encoding @exclude = exclude end |
Instance Attribute Details
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
6 7 8 |
# File 'lib/goodcheck/glob.rb', line 6 def encoding @encoding end |
#exclude ⇒ Object (readonly)
Returns the value of attribute exclude.
7 8 9 |
# File 'lib/goodcheck/glob.rb', line 7 def exclude @exclude end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
5 6 7 |
# File 'lib/goodcheck/glob.rb', line 5 def pattern @pattern end |
Instance Method Details
#==(other) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/goodcheck/glob.rb', line 19 def ==(other) other.is_a?(Glob) && other.pattern == pattern && other.encoding == encoding && other.exclude == exclude end |
#test(path) ⇒ Object
15 16 17 |
# File 'lib/goodcheck/glob.rb', line 15 def test(path) path.fnmatch?(pattern, FNM_FLAGS) && !excluded?(path) end |