app/controllers/anoubis/etc/filter.rb
##
# Initializes where parameters for filed with type number.
# @param key [Symbol] Filed identifier
# @param value [String] Filter parameters
Initializes where parameters for filed with type number.
Initializes where parameters for filed with type number .
def init_data_number(key, value)
        if value.index ','
          if self.fields[key].table_field.to_s.include? '.'
            self.attach_to_array self.fields[key].table_field.to_s + ' IN (?)'
            self.array.push(value.split ',')
          else
            self.hash[key] = value.split ','
          end
          return
        end
        if value.index '>'
          if value.to_s.include? '.'
            result_value = value.to_s[1..100].to_f
          else
            result_value = value.to_s[1..100].to_i
          end
          if self.fields[key].table_field.to_s.include? '.'
            self.attach_to_array self.fields[key].table_field.to_s + ' > ?'
            self.array.push(result_value)
          else
            self.hash[key] = [result_value..Float::INFINITY]
          end
          return
        end
        if value.index '<'
          if value.to_s.include? '.'
            result_value = value.to_s[1..100].to_f
          else
            result_value = value.to_s[1..100].to_i
          end
          if self.fields[key].table_field.to_s.include? '.'
            self.attach_to_array self.fields[key].table_field.to_s + ' < ?'
            self.array.push(result_value)
          else
            self.hash[key] = [-Float::INFINITY..result_value]
          end
          return
        end
        if value.index '-'
          data = value.split '-'
          if data[0].include? '.'
            min_value = data[0].to_f
          else
            min_value = data[0].to_i
          end
          if data[1].include? '.'
            max_value = data[1].to_f
          else
            max_value = data[1].to_i
          end
          min_value, max_value = max_value, min_value if min_value > max_value
          if self.fields[key].table_field.to_s.include? '.'
            self.attach_to_array self.fields[key].table_field.to_s + ' > ? AND ' + self.fields[key].table_field.to_s + ' < ?'
            self.array.push(min_value)
            self.array.push(max_value)
          else
            self.hash[key] = [min_value..max_value]
          end
          return
        end
        if self.fields[key].table_field.to_s.include? '.'
          self.attach_to_array self.fields[key].table_field.to_s + ' = ?'
          self.array.push(value)
        else
          self.hash[key] = value
        end
      end
def init_data_number ( key , value ) if value . index ',' if self . fields [ key ] . table_field . to_s . include? '.' self . attach_to_array self . fields [ key ] . table_field . to_s + ' IN (?)' self . array . push ( value . split ',' ) else self . hash [ key ] = value . split ',' end return end if value . index '>' if value . to_s . include? '.' result_value = value . to_s [ 1 .. 100 ] . to_f else result_value = value . to_s [ 1 .. 100 ] . to_i end if self . fields [ key ] . table_field . to_s . include? '.' self . attach_to_array self . fields [ key ] . table_field . to_s + ' > ?' self . array . push ( result_value ) else self . hash [ key ] = [ result_value .. Float :: INFINITY ] end return end if value . index '<' if value . to_s . include? '.' result_value = value . to_s [ 1 .. 100 ] . to_f else result_value = value . to_s [ 1 .. 100 ] . to_i end if self . fields [ key ] . table_field . to_s . include? '.' self . attach_to_array self . fields [ key ] . table_field . to_s + ' < ?' self . array . push ( result_value ) else self . hash [ key ] = [ - Float :: INFINITY .. result_value ] end return end if value . index '-' data = value . split '-' if data [ 0 ] . include? '.' min_value = data [ 0 ] . to_f else min_value = data [ 0 ] . to_i end if data [ 1 ] . include? '.' max_value = data [ 1 ] . to_f else max_value = data [ 1 ] . to_i end min_value , max_value = max_value , min_value if min_value > max_value if self . fields [ key ] . table_field . to_s . include? '.' self . attach_to_array self . fields [ key ] . table_field . to_s + ' > ? AND ' + self . fields [ key ] . table_field . to_s + ' < ?' self . array . push ( min_value ) self . array . push ( max_value ) else self . hash [ key ] = [ min_value .. max_value ] end return end if self . fields [ key ] . table_field . to_s . include? '.' self . attach_to_array self . fields [ key ] . table_field . to_s + ' = ?' self . array . push ( value ) else self . hash [ key ] = value end end
Initializes where parameters for filed with type number.
Initializes where parameters for filed with type number .
key
None
value
None