Class: Trifle::Ruby::Operations::Timeseries::Increment

Inherits:
Object
  • Object
show all
Defined in:
lib/trifle/ruby/operations/timeseries/increment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**keywords) ⇒ Increment

Returns a new instance of Increment.



10
11
12
13
14
15
# File 'lib/trifle/ruby/operations/timeseries/increment.rb', line 10

def initialize(**keywords)
  @key = keywords.fetch(:key)
  @at = keywords.fetch(:at)
  @values = keywords.fetch(:values)
  @config = keywords[:config]
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/trifle/ruby/operations/timeseries/increment.rb', line 8

def key
  @key
end

#valuesObject (readonly)

Returns the value of attribute values.



8
9
10
# File 'lib/trifle/ruby/operations/timeseries/increment.rb', line 8

def values
  @values
end

Instance Method Details

#configObject



17
18
19
# File 'lib/trifle/ruby/operations/timeseries/increment.rb', line 17

def config
  @config || Trifle::Ruby.default
end

#performObject



21
22
23
24
25
26
27
28
29
# File 'lib/trifle/ruby/operations/timeseries/increment.rb', line 21

def perform
  config.ranges.map do |range|
    at = Nocturnal.new(@at, config: config).send(range)
    config.driver.inc(
      key: [key, range, at.to_i].join(config.separator),
      **values
    )
  end
end