class SoarAnalytics::ThresholdReporter
Public Class Methods
new(name:, info_threshold: 0, warn_threshold: nil, error_threshold: nil)
click to toggle source
Calls superclass method
SoarAnalytics::Reporter::new
# File lib/soar_analytics/threshold_reporter.rb, line 3 def initialize(name:, info_threshold: 0, warn_threshold: nil, error_threshold: nil) super(name) @thresholds = [ { 'level' => :error, 'threshold' => error_threshold}, { 'level' => :warn, 'threshold' => warn_threshold}, { 'level' => :info, 'threshold' => info_threshold} ] end
Public Instance Methods
report(value, flow_identifier = nil)
click to toggle source
Calls superclass method
SoarAnalytics::Reporter#report
# File lib/soar_analytics/threshold_reporter.rb, line 12 def report(value, flow_identifier = nil) audit_level = determine_highest_matching_auditing_level(value) super(simplify_numbers(value), audit_level, flow_identifier) if audit_level end
Private Instance Methods
determine_highest_matching_auditing_level(value)
click to toggle source
# File lib/soar_analytics/threshold_reporter.rb, line 19 def determine_highest_matching_auditing_level(value) @thresholds.each { | threshold | return threshold['level'] if threshold['threshold'] and (value >= threshold['threshold']) } return nil end
simplify_numbers(value)
click to toggle source
# File lib/soar_analytics/threshold_reporter.rb, line 26 def simplify_numbers(value) return "%.6f" % value if value.is_a?(Float) return value end