Sha256: 41d7b08dd30c97936e1adda1cb235a86493137141101a7dd69e041553244309d

Contents?: true

Size: 724 Bytes

Versions: 46

Compression:

Stored size: 724 Bytes

Contents

require "json" unless defined?(JSON)

module Inspec; end

# A minimal Dataseries Object
# Stores the name of the data series and an array of data.
# Stored data should be a object that supports #to_s
module Inspec::Telemetry
  class DataSeries
    def initialize(name)
      @name = name
      @enabled = true
      @data ||= []
    end

    attr_reader :data, :name

    # This needs to also be set by configuration.
    def enabled?
      @enabled
    end

    def disable
      @enabled = false
    end

    def <<(appending_data)
      data << appending_data
    end

    alias push <<

    def to_h
      {
        name: @name,
        data: @data,
      }
    end

    def to_json
      to_h.to_json
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
inspec-core-5.22.58 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.22.55 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.22.40 lib/inspec/utils/telemetry/data_series.rb
inspec-core-6.6.0 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.22.36 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.22.29 lib/inspec/utils/telemetry/data_series.rb
inspec-core-4.56.58 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.22.3 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.21.29 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.18.14 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.17.4 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.14.0 lib/inspec/utils/telemetry/data_series.rb
inspec-core-4.56.20 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.12.2 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.10.5 lib/inspec/utils/telemetry/data_series.rb
inspec-core-4.56.19 lib/inspec/utils/telemetry/data_series.rb
inspec-core-5.7.9 lib/inspec/utils/telemetry/data_series.rb
inspec-core-4.56.17 lib/inspec/utils/telemetry/data_series.rb
inspec-core-4.52.9 lib/inspec/utils/telemetry/data_series.rb
inspec-core-4.50.3 lib/inspec/utils/telemetry/data_series.rb