lib/sycsvpro/filter.rb
def match_boolean_filter?(values=[])
      return false if boolean_filter.empty? or values.empty?
      expression = boolean_filter
      columns = expression.scan(/(([nsd])(\d+))([<!=~>]{1,2})(.*?)(?:[\|&]{2}|$)/)
      columns.each do |c|
        value = case c[1]
        when 'n'
          values[c[2].to_i].empty? ? '0' : values[c[2].to_i]
        when 's'
          "\"#{values[c[2].to_i]}\""
        when 'd'
          begin
            Date.strptime(values[c[2].to_i], date_format)
          rescue Exception => e
            case c[3]
            when '<', '<=', '=='
              "#{c[4]}+1"
            when '>', '>='
              '0'
            when '!='
              c[4]
            end
          else
            "Date.strptime('#{values[c[2].to_i]}', '#{date_format}')"
          end 
        end
        expression = expression.gsub(c[0], value)
      end
      eval(expression)
    end
def match_boolean_filter?(values=[])
      return false if boolean_filter.empty? or values.empty?
      expression = boolean_filter
      columns = expression.scan(/(([nsd])(\d+))([<!=~>]{1,2})(.*?)(?:[\|&]{2}|$)/)
      columns.each do |c|
        value = case c[1]
        when 'n'
          values[c[2].to_i].empty? ? '0' : values[c[2].to_i]
        when 's'
          "\"#{values[c[2].to_i]}\""
        when 'd'
          begin
            Date.strptime(values[c[2].to_i], date_format)
          rescue Exception => e
            case c[3]
            when '<', '<=', '=='
              "#{c[4]}+1"
            when '>', '>='
              '0'
            when '!='
              c[4]
            end
          else
            "Date.strptime('#{values[c[2].to_i]}', '#{date_format}')"
          end 
        end
        expression = expression.gsub(c[0], value)
      end
      eval(expression)
    end
def match_boolean_filter? ( values = [ ] ) return false if boolean_filter . empty? or values . empty? expression = boolean_filter columns = expression . scan ( / \d \| / ) columns . each do | c | value = case c [ 1 ] when 'n' values [ c [ 2 ] . to_i ] . empty? ? '0' : values [ c [ 2 ] . to_i ] when 's' "\"#{values[c[2].to_i]}\"" when 'd' begin Date . strptime ( values [ c [ 2 ] . to_i ] , date_format ) rescue Exception => e case c [ 3 ] when '<' , '<=' , '==' "#{c[4]}+1" when '>' , '>=' '0' when '!=' c [ 4 ] end else "Date.strptime('#{values[c[2].to_i]}', '#{date_format}')" end end expression = expression . gsub ( c [ 0 ] , value ) end eval ( expression ) end
Checks whether the values match the boolean filter
Checks whether the values match the boolean filter