Class: Trifle::Stats::Operations::Timeseries::Set

Inherits:
Object
  • Object
show all
Defined in:
lib/trifle/stats/operations/timeseries/set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**keywords) ⇒ Set

Returns a new instance of Set.



10
11
12
13
14
15
# File 'lib/trifle/stats/operations/timeseries/set.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/stats/operations/timeseries/set.rb', line 8

def key
  @key
end

#valuesObject (readonly)

Returns the value of attribute values.



8
9
10
# File 'lib/trifle/stats/operations/timeseries/set.rb', line 8

def values
  @values
end

Instance Method Details

#configObject



17
18
19
# File 'lib/trifle/stats/operations/timeseries/set.rb', line 17

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

#key_for(range:) ⇒ Object



21
22
23
24
# File 'lib/trifle/stats/operations/timeseries/set.rb', line 21

def key_for(range:)
  at = Nocturnal.new(@at, config: config).send(range)
  [key, range, at.to_i]
end

#performObject



26
27
28
29
30
31
# File 'lib/trifle/stats/operations/timeseries/set.rb', line 26

def perform
  config.driver.set(
    keys: config.ranges.map { |range| key_for(range: range) },
    **values
  )
end