Class: Trifle::Ruby::Operations::Timeseries::Values

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**keywords) ⇒ Values

Returns a new instance of Values.



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

def initialize(**keywords)
  @key = keywords.fetch(:key)
  @from = keywords.fetch(:from)
  @to = keywords.fetch(:to)
  @range = keywords.fetch(:range)
  @config = keywords[:config]
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#rangeObject (readonly)

Returns the value of attribute range.



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

def range
  @range
end

Instance Method Details

#configObject



18
19
20
# File 'lib/trifle/ruby/operations/timeseries/values.rb', line 18

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

#performObject



26
27
28
29
30
31
32
33
34
# File 'lib/trifle/ruby/operations/timeseries/values.rb', line 26

def perform
  timeline.map do |at|
    {
      at => config.driver.get(
        key: [key, range, at.to_i].join(config.separator)
      )
    }
  end
end

#timelineObject



22
23
24
# File 'lib/trifle/ruby/operations/timeseries/values.rb', line 22

def timeline
  Nocturnal.timeline(from: @from, to: @to, range: range)
end