blob: db9254876f981590b557516924e6939860e4217b (
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
|
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?(key, value)
case @from <=> value
when -1
return false
when 0
return false if !@from_inclusive
end
case @to <=> value
when 1
return false
when 0
return false if !@to_inclusive
end
return true
end
end
end
end
end
|