Class: CssClassDuplicates::Filter
- Inherits:
-
Object
- Object
- CssClassDuplicates::Filter
- Defined in:
- lib/css_class_duplicates/filter.rb
Overview
This class filters found results to exclude CSS classes that aren’t duplicated
Instance Method Summary collapse
- #call(entities) ⇒ Object
-
#initialize(config) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(config) ⇒ Filter
Returns a new instance of Filter.
6 7 8 9 |
# File 'lib/css_class_duplicates/filter.rb', line 6 def initialize(config) @min_classes = config.dig('classes', 'min') || 2 @min_matches = config.dig('matches', 'min') || 2 end |
Instance Method Details
#call(entities) ⇒ Object
11 12 13 14 15 |
# File 'lib/css_class_duplicates/filter.rb', line 11 def call(entities) entities.select do |entity| entity.classes.size >= @min_classes && entity.files.size >= @min_matches end end |