Class: RRD::CDP

Inherits:
Object
  • Object
show all
Defined in:
lib/rrd/cdp.rb

Constant Summary collapse

CDP_val =
0
CDP_unkn_pdp_cnt =
1
CDP_hw_intercept =
2
CDP_hw_seasonal =
2
CDP_seasonal_deviation =
2
CDP_hw_last_intercept =
3
CDP_hw_last_seasonal =
3
CDP_last_seasonal_deviation =
3
CDP_hw_slope =
4
CDP_hw_last_slope =
5
CDP_null_count =
6
CDP_init_seasonal =
6
CDP_last_null_count =
7
CDP_primary_val =
8
CDP_secondary_val =
9

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CDP

Returns a new instance of CDP.



19
20
21
# File 'lib/rrd/cdp.rb', line 19

def initialize(options)
  @options = options
end

Class Method Details

.parse(reader, rra) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rrd/cdp.rb', line 23

def self.parse(reader, rra)
  params = reader.read_uniparams(10)

  options = {
    primary_value: params[CDP_primary_val].to_f,
    secondary_value: params[CDP_secondary_val].to_f
  }

  case rra.cf
  when :hwpredict, :mhwpredict
    options[:intercept] = params[CDP_hw_intercept].to_f
    options[:last_intercept] = params[CDP_hw_intercept].to_f
    options[:slope] = params[CDP_hw_intercept].to_f
    options[:last_slope] = params[CDP_hw_intercept].to_f
    options[:null_count] = params[CDP_hw_intercept].to_i
    options[:last_null_count] = params[CDP_hw_intercept].to_i
  when :seasonal
    options[:seasonal] = params[CDP_hw_seasonal].to_f
    options[:last_seasonal] = params[CDP_hw_last_seasonal].to_f
    options[:init_seasonal] = params[CDP_init_seasonal].to_i
  when :devseasonal
    options[:seasonal_deviation] = params[CDP_seasonal_deviation].to_f
    options[:last_seasonal_deviation] = params[CDP_last_seasonal_deviation].to_f
    options[:init_seasonal] = params[CDP_init_seasonal].to_i
  else
    options[:value] = params[CDP_val].to_f
    options[:unknown_datapoints] = params[CDP_unkn_pdp_cnt].to_i
  end

  new(options)
end