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, line 16
def process_result(value, reply)
  @result[:value] += value
  @count += 1
end
startup_hook() click to toggle source

Before function is run processing

# File lib/mcollective/aggregate/average.rb, line 5
def startup_hook
  @result[:value] = 0
  @result[:type] = :numeric

  @count = 0

  # Set default aggregate_function if it is undefined
  @aggregate_format = "Average of #{@result[:output]}: %f" unless @aggregate_format
end
summarize() click to toggle source

Stops execution of the function and returns a ResultObject

# File lib/mcollective/aggregate/average.rb, line 22
def summarize
  @result[:value] /= @count

  result_class(:numeric).new(@result, @aggregate_format, @action)
end