Class: NcsNavigator::Warehouse::Filters::CodedAsMissingFilter
- Inherits:
-
Object
- Object
- NcsNavigator::Warehouse::Filters::CodedAsMissingFilter
- Defined in:
- lib/ncs_navigator/warehouse/filters/coded_as_missing_filter.rb
Overview
Some source data sets include unnecessary placeholder records and values. This filter excludes the following variables and records:
Entire records whose ID is one of the common MDES error codes (-3, -4, -6, -7).
Foreign key values whose ID is one of those same MDES error codes.
Variable values which are not required and not coded whose value is one of these error codes (e.g., a comments field whose value is '-7').
If the :additional_codes
option is passed to the constructor,
those codes will be used in addition to the default list (i.e.,
-3, -4, -6, -7).
This filter may be used with or without instantiation.
Constant Summary collapse
- DEFAULT_MISSING_CODES =
%w(-3 -4 -6 -7)
Instance Attribute Summary collapse
-
#missing_codes ⇒ Object
readonly
Returns the value of attribute missing_codes.
Class Method Summary collapse
Instance Method Summary collapse
- #call(records) ⇒ Object
-
#initialize(configuration = nil, options = {}) ⇒ CodedAsMissingFilter
constructor
A new instance of CodedAsMissingFilter.
Constructor Details
#initialize(configuration = nil, options = {}) ⇒ CodedAsMissingFilter
Returns a new instance of CodedAsMissingFilter.
46 47 48 49 50 51 |
# File 'lib/ncs_navigator/warehouse/filters/coded_as_missing_filter.rb', line 46 def initialize(configuration=nil, ={}) @missing_codes = DEFAULT_MISSING_CODES.dup if [:additional_codes] @missing_codes += [:additional_codes] end end |
Instance Attribute Details
#missing_codes ⇒ Object (readonly)
Returns the value of attribute missing_codes.
38 39 40 |
# File 'lib/ncs_navigator/warehouse/filters/coded_as_missing_filter.rb', line 38 def missing_codes @missing_codes end |
Class Method Details
.call(records) ⇒ Object
27 28 29 |
# File 'lib/ncs_navigator/warehouse/filters/coded_as_missing_filter.rb', line 27 def call(records) singleton.call(records) end |
Instance Method Details
#call(records) ⇒ Object
53 54 55 |
# File 'lib/ncs_navigator/warehouse/filters/coded_as_missing_filter.rb', line 53 def call(records) records.collect { |r| process(r) }.compact end |