Class: Probe::ColumnIsEqualTo

Inherits:
ColumnMeetsCondition show all
Defined in:
lib/csv/probe/checks.rb

Overview

Check if a column value is equal to a provided value (Pay attention to types!)

Instance Attribute Summary

Attributes inherited from ColumnMeetsCondition

#fail_msg, #ok_condition_fn, #varname

Attributes inherited from RowMeetsCondition

#fail_msg, #ok_condition_fn, #pre_checks, #severity

Instance Method Summary collapse

Methods inherited from ColumnMeetsCondition

#evaluate, #render_pretty_fail_msg

Methods inherited from RowMeetsCondition

#error_msg, #evaluate, #evaluate_pre_checks, #render_fail_msg, #render_pretty_fail_msg, #report_columns_hash, #source_row, #source_row_location

Constructor Details

#initialize(varname, expected_val, _placeholder = nil) ⇒ ColumnIsEqualTo

Returns a new instance of ColumnIsEqualTo.



140
141
142
143
144
# File 'lib/csv/probe/checks.rb', line 140

def initialize(varname, expected_val, _placeholder = nil)
  super(varname, nil, nil)
  @ok_condition_fn = ->(val, _cfg) { val == expected_val }
  @fail_msg = "expected to be #{expected_val.inspect}"
end