Class: SimpleCov::Filter
- Inherits:
-
Object
- Object
- SimpleCov::Filter
- Defined in:
- lib/simplecov/filter.rb,
sig/simplecov.rbs
Overview
Base filter class. Inherit and override matches? to create custom
filters. T is the type of the configured filter argument.
Direct Known Subclasses
ArrayFilter, BlockFilter, GlobFilter, RegexFilter, StringFilter
Instance Attribute Summary collapse
-
#filter_argument ⇒ T
readonly
Returns the value of attribute filter_argument.
Class Method Summary collapse
- .build_filter(filter_argument) ⇒ Filter[untyped]
- .class_for_argument(filter_argument) ⇒ singleton(Filter)
Instance Method Summary collapse
-
#initialize(filter_argument) ⇒ Filter
constructor
A new instance of Filter.
-
#matches?(_source_file) ⇒ boolish
The base implementation raises NotImplementedError.
Constructor Details
#initialize(filter_argument) ⇒ Filter
Returns a new instance of Filter.
18 19 20 |
# File 'lib/simplecov/filter.rb', line 18 def initialize(filter_argument) @filter_argument = filter_argument end |
Instance Attribute Details
#filter_argument ⇒ T (readonly)
Returns the value of attribute filter_argument.
16 17 18 |
# File 'lib/simplecov/filter.rb', line 16 def filter_argument @filter_argument end |
Class Method Details
.build_filter(filter_argument) ⇒ Filter[untyped]
26 27 28 29 30 |
# File 'lib/simplecov/filter.rb', line 26 def self.build_filter(filter_argument) return filter_argument if filter_argument.is_a?(SimpleCov::Filter) class_for_argument(filter_argument).new(filter_argument) end |
.class_for_argument(filter_argument) ⇒ singleton(Filter)
32 33 34 35 |
# File 'lib/simplecov/filter.rb', line 32 def self.class_for_argument(filter_argument) filter_classes_by_argument_type.find { |type, _| filter_argument.is_a?(type) }&.last || raise(SimpleCov::ConfigurationError, "You have provided an unrecognized filter type") end |
Instance Method Details
#matches?(_source_file) ⇒ boolish
The base implementation raises NotImplementedError.
1162 1163 1164 |
# File 'sig/simplecov.rbs', line 1162 def matches?(_source_file) raise NotImplementedError, "The base filter class is not intended for direct use" end |