Class: Trifle::Stats::Operations::Timeseries::Increment

Inherits:
Object
  • Object
show all
Defined in:
lib/trifle/stats/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
16
# File 'lib/trifle/stats/operations/timeseries/increment.rb', line 10

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

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#valuesObject (readonly)

Returns the value of attribute values.



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

def values
  @values
end

Instance Method Details

#configObject



18
19
20
# File 'lib/trifle/stats/operations/timeseries/increment.rb', line 18

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

#key_for(granularity:) ⇒ Object



22
23
24
25
26
# File 'lib/trifle/stats/operations/timeseries/increment.rb', line 22

def key_for(granularity:)
  pgrn = Nocturnal::Parser.new(granularity)
  at = Nocturnal.new(localized_time(@at), config: config).floor(pgrn.offset, pgrn.unit)
  Nocturnal::Key.new(key: key, granularity: granularity, at: at)
end

#performObject



28
29
30
31
32
# File 'lib/trifle/stats/operations/timeseries/increment.rb', line 28

def perform
  return direct_write if direct_write?

  buffered_write
end

#tracking_keyObject



34
35
36
# File 'lib/trifle/stats/operations/timeseries/increment.rb', line 34

def tracking_key
  @untracked ? '__untracked__' : nil
end