blob: afa3fa2786fee03647cf49c27f2df7920b37c753 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
module ChefZero
module Solr
module Query
class RangeQuery
def initialize(from, to, from_inclusive, to_inclusive)
@from = from
@to = to
@from_inclusive = from_inclusive
@to_inclusive = to_inclusive
end
def to_s
"#{@from_inclusive ? '[' : '{'}#{@from} TO #{@to}#{@to_inclusive ? ']' : '}'}"
end
def matches_values?(values)
value = values.first
case @from <=> value
when -1
return false
when 0
return false if !@from_inclusive
end
case value <=> @to
when 1
return false
when 0
return false if !@to_inclusive
end
return true
end
end
end
end
end
|