Sha256: fbcd334791c07b85dde1e0d54898f4aea1b535579c195a62dfc00c9f8c49d072

Contents?: true

Size: 1013 Bytes

Versions: 2

Compression:

Stored size: 1013 Bytes

Contents

require 'update_repo/version'
require 'update_repo/helpers'

module UpdateRepo
  # Class : Metrics.
  # This class takes care of storing the metrics for processed, failures, etc.
  class Metrics
    include Helpers

    # Constructor for the Metrics class.
    # @param logger [instance] Pointer to the Logger class
    # @return [instance] Instance of the Metrics class
    def initialize(logger)
      @log = logger
      @metrics = { processed: 0, skipped: 0, failed: 0, updated: 0,
                   unchanged: 0, start_time: 0, failed_list: [],
                   warning: 0 }
    end

    # Read the metric 'key'
    # @param key [symbol] the key to read
    # @return [various] Return the value for hash key 'key'
    def [](key)
      @metrics[key]
    end

    # Set the metric 'key' to 'value'
    # @param key [symbol] the key to set
    # @param value [symbol] set 'key' to this value.
    # @return [value] Return the value set.
    def []=(key, value)
      @metrics[key] = value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
update_repo-0.9.9 lib/update_repo/metrics.rb
update_repo-0.9.8 lib/update_repo/metrics.rb