Sha256: a0a37adbd1d726a61638ec5c72728ae5290be0002a0a1157409e90f7c6c350a8
Contents?: true
Size: 835 Bytes
Versions: 5
Compression:
Stored size: 835 Bytes
Contents
module MetricFu class Hotspot def self.metric self.name.split('Hotspot')[0].downcase.to_sym end @analyzers = {} def self.analyzers @analyzers.values end def self.analyzer_for_metric(metric) mf_debug "Getting analyzer for #{metric}" @analyzers.fetch(metric.to_sym) { raise MetricFu::AnalysisError, "Unknown metric #{metric}. We only know #{@analyzers.keys.inspect}" } end def self.inherited(subclass) mf_debug "Adding #{subclass} to #{@analyzers.inspect}" @analyzers[subclass.metric] = subclass.new end # TODO simplify calculation def get_mean(collection) collection_length = collection.length sum = 0 sum = collection.inject( nil ) { |sum,x| sum ? sum+x : x } (sum.to_f / collection_length.to_f) end end end
Version data entries
5 entries across 5 versions & 1 rubygems