Class: Influxdb::Arel::Nodes::Duration
- Inherits:
-
Binary
- Object
- Node
- Binary
- Influxdb::Arel::Nodes::Duration
show all
- Defined in:
- lib/influxdb/arel/nodes/duration.rb
Constant Summary
collapse
- POSSIBLE_SUFFIXES =
%w{u s m h d w}.freeze
Instance Attribute Summary
Attributes inherited from Binary
#left, #right
Instance Method Summary
collapse
Methods inherited from Binary
#eql?, #hash, #initialize_copy
Methods inherited from Node
#and, #or, #to_sql
Constructor Details
#initialize(value, suffix) ⇒ Duration
Returns a new instance of Duration.
10
11
12
13
14
|
# File 'lib/influxdb/arel/nodes/duration.rb', line 10
def initialize(value, suffix)
suffix = suffix.to_s
suffix = 'u' unless POSSIBLE_SUFFIXES.include?(suffix)
super(value.to_i, suffix)
end
|
Instance Method Details
#ago ⇒ Object
20
21
22
|
# File 'lib/influxdb/arel/nodes/duration.rb', line 20
def ago
Arel.now - self
end
|
#since ⇒ Object
24
25
26
|
# File 'lib/influxdb/arel/nodes/duration.rb', line 24
def since
Arel.now + self
end
|
#time ⇒ Object
16
17
18
|
# File 'lib/influxdb/arel/nodes/duration.rb', line 16
def time
Arel.time(self)
end
|