Class: FastIgnore::Matchers::WithinDir
- Inherits:
-
Object
- Object
- FastIgnore::Matchers::WithinDir
- Defined in:
- lib/fast_ignore/matchers/within_dir.rb
Instance Attribute Summary collapse
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(matchers, root) ⇒ WithinDir
constructor
A new instance of WithinDir.
- #match?(candidate) ⇒ Boolean
Constructor Details
#initialize(matchers, root) ⇒ WithinDir
Returns a new instance of WithinDir.
8 9 10 11 12 13 14 15 16 |
# File 'lib/fast_ignore/matchers/within_dir.rb', line 8 def initialize(matchers, root) @dir_matchers = squash_matchers(matchers.reject(&:file_only?)) @file_matchers = squash_matchers(matchers.reject(&:dir_only?)) @weight = @dir_matchers.sum(&:weight) + @file_matchers.sum(&:weight) @root = root freeze end |
Instance Attribute Details
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
6 7 8 |
# File 'lib/fast_ignore/matchers/within_dir.rb', line 6 def weight @weight end |
Instance Method Details
#empty? ⇒ Boolean
30 31 32 |
# File 'lib/fast_ignore/matchers/within_dir.rb', line 30 def empty? @dir_matchers.empty? && @file_matchers.empty? end |
#match?(candidate) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fast_ignore/matchers/within_dir.rb', line 18 def match?(candidate) relative_candidate = candidate.relative_to(@root) return false unless relative_candidate (candidate.directory? ? @dir_matchers : @file_matchers).reverse_each do |rule| val = rule.match?(relative_candidate) return val if val end false end |