Skip to content

Commit

Permalink
Merge pull request #273 from vogogo/filter-negative-numbers
Browse files Browse the repository at this point in the history
Allow filtering by negative numbers
  • Loading branch information
leikind committed Jan 29, 2016
2 parents 905ab75 + a7e227e commit 3796228
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/wice/columns/column_integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def get_op_and_value(val) #:nodoc:
# remove spaces
val = val.gsub(' ', '')

first_digit_or_dot_index = val =~ /[0-9.]/
if first_digit_or_dot_index
op = val[0...first_digit_or_dot_index]
start_of_num = val =~ /[0-9.-]/ # first digit, dot or negative sign
if start_of_num
op = val[0...start_of_num]
op = '=' if op == ''
num = Float(val[first_digit_or_dot_index..-1]) rescue nil
num = Float(val[start_of_num..-1]) rescue nil

op = nil unless ['<', '>', '<=', '>=', '='].include?(op)
end
Expand Down

0 comments on commit 3796228

Please sign in to comment.