Class: Kiba::Extend::Transforms::FilterRows::WithLambda
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::FilterRows::WithLambda
- Includes:
- ActionArgumentable, BooleanLambdaParamable
- Defined in:
- lib/kiba/extend/transforms/filter_rows/with_lambda.rb
Overview
Keep or reject rows based on whether the arbitrary Lambda passed in evaluates to true/false
Instance Method Summary collapse
-
#initialize(action:, lambda:) ⇒ WithLambda
constructor
A new instance of WithLambda.
-
#process(row) ⇒ Object
Methods included from BooleanLambdaParamable
included, #lambda_tested, #test_lambda
Constructor Details
#initialize(action:, lambda:) ⇒ WithLambda
Returns a new instance of WithLambda.
80 81 82 83 84 |
# File 'lib/kiba/extend/transforms/filter_rows/with_lambda.rb', line 80 def initialize(action:, lambda:) validate_action_argument(action) @action = action @lambda = lambda end |
Instance Method Details
#process(row) ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/kiba/extend/transforms/filter_rows/with_lambda.rb', line 87 def process(row) test_lambda(row) unless lambda_tested case action when :keep row if lambda.call(row) when :reject row unless lambda.call(row) end end |