Sha256: 3cc73dba7a23156d561a0271f59b43aeeb720f8ba5dc8e3fbf2cf50ca2d2e57a

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 Bytes

Contents

# frozen_string_literal: true

module Trifle
  module Stats
    module Operations
      module Timeseries
        class Values
          attr_reader :key, :range

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

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trifle-stats-0.2.1 lib/trifle/stats/operations/timeseries/values.rb
trifle-stats-0.2.0 lib/trifle/stats/operations/timeseries/values.rb
trifle-stats-0.1.0 lib/trifle/stats/operations/timeseries/values.rb