Sha256: 8efb069af200452f1ddb6d2c45f5e74d12543906bda4221402fb25399eb2bbca
Contents?: true
Size: 850 Bytes
Versions: 2
Compression:
Stored size: 850 Bytes
Contents
# frozen_string_literal: true module Sail # Instrumenter # # Class containing methods to instrument # setting usage and provide insights to # dashboard users. class Instrumenter # initialize # # Declare basic hash containing setting # statistics def initialize @statistics = Hash.new(0).with_indifferent_access end # increment_usage # # Simply increments the number of # times a setting has been called def increment_usage_of(setting_name) @statistics[setting_name] += 1 end # relative_usage_of # # Calculates the relative usage of # a setting compared to all others # in percentage def relative_usage_of(setting_name) return 0.0 if @statistics.empty? (100.0 * @statistics[setting_name]) / @statistics.values.reduce(:+) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sail-3.0.1 | lib/sail/instrumenter.rb |
sail-3.0.0 | lib/sail/instrumenter.rb |