Sha256: fdd60a6d91905d15b22092dcdb62af546dc7bafe9859c7e90e1709d87fd9ce80
Contents?: true
Size: 1.76 KB
Versions: 11
Compression:
Stored size: 1.76 KB
Contents
module CMSScanner module Finders # Confidence class Confidence < Numeric attr_reader :value def initialize(value) @value = value end # @param [ Integer, Confidence ] other # # TODO: rework the formula which is weak when the value to add is < the current confidence # e.g: 90 + 50 + 30 => 82 # # @return [ Confidence ] A new Confidence def +(other) return Confidence.new(100) if @value == 100 to_add = other_value(other) new_value = (@value + to_add) / 1.5 new_value = 100 if new_value > 100 || to_add == 100 Confidence.new(new_value.floor) end # ## Convenient Methods # #:nocov: def to_s @value.to_s end def to_json @value.to_json end # @param [ Integer, Confidence ] other def other_value(other) other.is_a?(Confidence) ? other.value : other end # @param [ Integer, Confidence ] other def ==(other) @value == other_value(other) end # @param [ Integer, Confidence ] other def eql?(other) @value.eql?(other_value(other)) end # @param [ Integer, Confidence ] other def <(other) @value < other_value(other) end # @param [ Integer, Confidence ] other def <=(other) @value <= other_value(other) end # @param [ Integer, Confidence ] other def >(other) @value > other_value(other) end # @param [ Integer, Confidence ] other def >=(other) @value >= other_value(other) end # @param [ Integer, Confidence ] other def <=>(other) @value <=> other_value(other) end #:nocov: end end end
Version data entries
11 entries across 11 versions & 1 rubygems