class MCollective::Aggregate::Average - mcollective version 2.12.5

# class MCollective::Aggregate::Average

### Public Instance Methods

process_result(value, reply) click to toggle source

Determines the average of a set of numerical values

       # File lib/mcollective/aggregate/average.rb
    16 def process_result(value, reply)
    17   @result[:value] += value
    18   @count += 1
    19 end

startup_hook() click to toggle source

Before function is run processing

       # File lib/mcollective/aggregate/average.rb
     5 def startup_hook
     6   @result[:value] = 0
     7   @result[:type] = :numeric
     8
     9   @count = 0
    10
    11   # Set default aggregate_function if it is undefined
    12   @aggregate_format = "Average of #{@result[:output]}: %f" unless @aggregate_format
    13 end

summarize() click to toggle source

Stops execution of the function and returns a ResultObject

       # File lib/mcollective/aggregate/average.rb
    22 def summarize
    23   @result[:value] /= @count
    24
    25   result_class(:numeric).new(@result, @aggregate_format, @action)
    26 end