class Probe::ColumnIsSet
Check if a tokenized column value is a list of given values
Public Class Methods
new(varname, separator, _placeholder = nil)
click to toggle source
Calls superclass method
Probe::ColumnMeetsCondition::new
# File lib/csv/probe/checks.rb, line 215 def initialize(varname, separator, _placeholder = nil) # rubocop:disable Metrics/MethodLength super(varname, nil, nil) @ok_condition_fn = lambda { |val, _cfg| return true if val.to_s == "" items = val.to_s.split(separator, -1) all_uniq = (items.size == items.uniq.size) return all_uniq } @fail_msg = lambda { |row, _opts| items = row.fetch(@varname).to_s.split(separator, -1) non_uniq_items = items.detect { |e| items.count(e) > 1 } "expected that items of tokenized value #{items.inspect} are uniqe, but items #{non_uniq_items.inspect} are not" } end