Class: Trifle::Stats::Operations::Timeseries::Set
- Inherits:
-
Object
- Object
- Trifle::Stats::Operations::Timeseries::Set
- Defined in:
- lib/trifle/stats/operations/timeseries/set.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(**keywords) ⇒ Set
constructor
A new instance of Set.
- #key_for(range:) ⇒ Object
- #perform ⇒ Object
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
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/trifle/stats/operations/timeseries/set.rb', line 8 def key @key end |
#values ⇒ Object (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
#config ⇒ Object
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 |
#perform ⇒ Object
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 |