Class: Kiba::Extend::Utils::Lookup::PairInclusion
- Inherits:
-
Object
- Object
- Kiba::Extend::Utils::Lookup::PairInclusion
- Defined in:
- lib/kiba/extend/utils/lookup/pair_inclusion.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(pair:, row:, mergerow: {}) ⇒ PairInclusion
constructor
A new instance of PairInclusion.
Constructor Details
#initialize(pair:, row:, mergerow: {}) ⇒ PairInclusion
Returns a new instance of PairInclusion.
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 |
# File 'lib/kiba/extend/utils/lookup/pair_inclusion.rb', line 10 def initialize(pair:, row:, mergerow: {}) comparison_type = :include pair = pair.map { |e| e.split("::") } # convert row or mergerow fieldnames to symbols pair = pair.each { |arr| arr[1] = arr[1].to_sym if arr[0]["row"] } # fetch or convert values for comparison pair = pair.map do |arr| case arr[0] when "row" row.fetch(arr[1], nil) when "mergerow" mergerow.fetch(arr[1], nil) when "revalue" comparison_type = :match Regexp.new(arr[1]) when "value" arr[1] end end if pair[0].nil? @result = false else case comparison_type when :include @result = pair[0].include?(pair[1]) when :match @result = pair[0].match?(pair[1]) end end end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
8 9 10 |
# File 'lib/kiba/extend/utils/lookup/pair_inclusion.rb', line 8 def result @result end |