Sha256: 25a11cf76db8cfe1c812ff12ab98a8b17f0eccddc9418573dd5a05cff9346764
Contents?: true
Size: 754 Bytes
Versions: 41
Compression:
Stored size: 754 Bytes
Contents
module MCollective class Aggregate class Average<Base # Before function is run processing 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 # Determines the average of a set of numerical values def process_result(value, reply) @result[:value] += value @count += 1 end # Stops execution of the function and returns a ResultObject def summarize @result[:value] /= @count result_class(:numeric).new(@result, @aggregate_format, @action) end end end end
Version data entries
41 entries across 41 versions & 2 rubygems
Version | Path |
---|---|
mcollective-client-2.8.0 | lib/mcollective/aggregate/average.rb |