Class: Kiba::Extend::Utils::Lookup::SetChecker
- Inherits:
-
Object
- Object
- Kiba::Extend::Utils::Lookup::SetChecker
- Defined in:
- lib/kiba/extend/utils/lookup/set_checker.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#set_type ⇒ Object
readonly
Returns the value of attribute set_type.
Instance Method Summary collapse
-
#initialize(check_type:, set:, row:, mergerow: {}, sep: nil) ⇒ SetChecker
constructor
A new instance of SetChecker.
Constructor Details
#initialize(check_type:, set:, row:, mergerow: {}, sep: nil) ⇒ SetChecker
Returns a new instance of SetChecker.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/kiba/extend/utils/lookup/set_checker.rb', line 10 def initialize(check_type:, set:, row:, mergerow: {}, sep: nil) @check_type = check_type @set_type = set[:type] || :any bool = [] case @check_type when :equality set[:matches].each do |pair| chk = pair.select { |e| e.start_with?("mv") } if chk.empty? bool << Lookup::PairEquality.new( pair: pair, row: row, mergerow: mergerow ).result else bool << Lookup::SetChecker.new( check_type: :equality, set: { type: :any, matches: Lookup::MultivalPairs.new(pair: pair, row: row, mergerow: mergerow, sep: sep).result }, row: {} ) end end when :emptiness set[:fields].each do |field| bool << Lookup::FieldEmptiness.new( field: field, row: row, mergerow: mergerow ).result end when :inclusion set[:includes].each do |pair| bool << Lookup::PairInclusion.new( pair: pair, row: row, mergerow: mergerow ).result end end case @set_type when :any @result = bool.any? when :all @result = !bool.any?(false) end end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
8 9 10 |
# File 'lib/kiba/extend/utils/lookup/set_checker.rb', line 8 def result @result end |
#set_type ⇒ Object (readonly)
Returns the value of attribute set_type.
8 9 10 |
# File 'lib/kiba/extend/utils/lookup/set_checker.rb', line 8 def set_type @set_type end |