我正试图想办法做到这一点,作为一个proc。本质上,唯一不同的部分是在子字符串上匹配它们是.include?而不是检查等于。包含红宝石的块/程序
def check_exact_match(lead_attribute, tracker_attribute)
return true if tracker_attribute.nil?
return true if lead_attribute.downcase == tracker_attribute.downcase
false
end
def check_substring_match(lead_attribute, tracker_attribute)
return true if tracker_attribute.nil?
return true if lead_attribute.downcase.include? tracker_attribute.downcase
return false
end
请注意'如果cond1返回true;如果cond2返回true;假'也可以写成'cond1 ||' cond2'。 – sepp2k