Class: UpdateRepo::Metrics

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/update_repo/metrics.rb

Overview

Class : Metrics. This class takes care of storing the metrics for processed, failures, etc.

Instance Method Summary collapse

Methods included from Helpers

#trunc_dir

Constructor Details

#initialize(logger) ⇒ instance

Constructor for the Metrics class.

Parameters:

  • logger (instance)

    Pointer to the Logger class



13
14
15
16
17
# File 'lib/update_repo/metrics.rb', line 13

def initialize(logger)
  @log = logger
  @metrics = { processed: 0, skipped: 0, failed: 0, updated: 0,
               unchanged: 0, start_time: 0, failed_list: [] }
end

Instance Method Details

#[](key) ⇒ various

Read the metric ‘key’

Parameters:

  • key (symbol)

    the key to read

Returns:

  • (various)

    Return the value for hash key ‘key’



22
23
24
# File 'lib/update_repo/metrics.rb', line 22

def [](key)
  @metrics[key]
end

#[]=(key, value) ⇒ value

Set the metric ‘key’ to ‘value’

Parameters:

  • key (symbol)

    the key to set

  • value (symbol)

    set ‘key’ to this value.

Returns:

  • (value)

    Return the value set.



30
31
32
# File 'lib/update_repo/metrics.rb', line 30

def []=(key, value)
  @metrics[key] = value
end