Module: Deli::Param::Number

Included in:
Adapters::ActiveRecord::Number, Adapters::Cassandra::Number, Adapters::Mongoid::Number, Adapters::Neo4j::Number, Adapters::Simple::Number
Defined in:
lib/deli/param.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) parse(value)



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/deli/param.rb', line 65

def parse(value)
  values  = []
  
  value.to_s.split(/[,\|]/).each do |string|
    if string =~ /([^\.]+)?(\.{2})([^\.]+)?/
      starts_on, operator, ends_on = $1, $2, $3
      range   = []
      range   << parse_value(starts_on, [">="]) if starts_on.present? && starts_on =~ /^\d/
      range   << parse_value(ends_on, ["<="])   if ends_on.present? && ends_on =~ /^\d/
      values  << range
    else
      values  << [parse_value(string, ["="])]
    end
  end
  
  values
end

- (Object) parse_value(value, operators)



83
84
85
# File 'lib/deli/param.rb', line 83

def parse_value(value, operators)
  super(value.to_i, operators) # or to_f ?
end