Class: CloudSesame::Query::AST::RangeValue
Constant Summary
collapse
- STRING_NUMBER =
Regexp.new(/^\d+(.\d+?)$/)
Abstract::Value::DATETIME_FORMAT, Abstract::Value::DATE_FORMAT, Abstract::Value::DIGIT_FORMAT, Abstract::Value::RANGE_FORMAT, Abstract::Value::TIME_FORMAT
Instance Attribute Summary
#changed, #compiled, #value
Instance Method Summary
collapse
#compile, datetime?, numeric?, range?, string_date?, string_datetime?, string_numeric?, string_range?, string_time?
Constructor Details
#initialize(value = nil, type = nil) ⇒ RangeValue
Returns a new instance of RangeValue.
8
9
10
11
12
13
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 8
def initialize(value = nil, type = nil)
self.value = RangeValue.range?(value) ? build_from_range(value) :
RangeValue.string_range?(value) ? build_from_string(value) :
initialize_value
self.parse type
end
|
Instance Method Details
#==(object) ⇒ Object
64
65
66
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 64
def ==(object)
value == (object.is_a?(RangeValue) ? object : RangeValue.new(object, Value)).value
end
|
#begin ⇒ Object
24
25
26
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 24
def begin
value[1]
end
|
#end ⇒ Object
28
29
30
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 28
def end
value[2]
end
|
#gt(value) ⇒ Object
40
41
42
43
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 40
def gt(value)
set_begin(value) if value
return self
end
|
#gte(value) ⇒ Object
45
46
47
48
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 45
def gte(value)
set_begin(value, '[') if value
return self
end
|
#lower_bound ⇒ Object
32
33
34
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 32
def lower_bound
value[0]
end
|
#lt(value) ⇒ Object
50
51
52
53
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 50
def lt(value)
set_end(value) if value
return self
end
|
#lte(value) ⇒ Object
55
56
57
58
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 55
def lte(value)
set_end(value, ']') if value
return self
end
|
#parse(type) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 15
def parse(type)
if type && type.respond_to?(:parse)
@changed = true
value[1] = type.parse(self.begin) unless self.begin.to_s.empty?
value[2] = type.parse(self.end) unless self.end.to_s.empty?
end
return self
end
|
#to_s ⇒ Object
60
61
62
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 60
def to_s
compile
end
|
#upper_bound ⇒ Object
36
37
38
|
# File 'lib/cloud_sesame/query/ast/range_value.rb', line 36
def upper_bound
value[3]
end
|