Class: CMSScanner::Finders::Confidence
- Defined in:
- lib/cms_scanner/finders/confidence.rb
Overview
Confidence
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#+(other) ⇒ Confidence
TODO: rework the formula which is weak when the value to add is < the current confidence e.g: 90 + 50 + 30 => 82.
- #<(other) ⇒ Object
- #<=(other) ⇒ Object
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #>(other) ⇒ Object
- #>=(other) ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(value) ⇒ Confidence
constructor
A new instance of Confidence.
- #other_value(other) ⇒ Object
- #to_json ⇒ Object
-
#to_s ⇒ Object
Convenient Methods.
Methods inherited from Numeric
Constructor Details
#initialize(value) ⇒ Confidence
Returns a new instance of Confidence.
7 8 9 |
# File 'lib/cms_scanner/finders/confidence.rb', line 7 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/cms_scanner/finders/confidence.rb', line 5 def value @value end |
Instance Method Details
#+(other) ⇒ Confidence
TODO: rework the formula which is weak when the value to add is < the current confidence e.g: 90 + 50 + 30 => 82
17 18 19 20 21 22 23 24 25 |
# File 'lib/cms_scanner/finders/confidence.rb', line 17 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 |
#<(other) ⇒ Object
55 56 57 |
# File 'lib/cms_scanner/finders/confidence.rb', line 55 def <(other) @value < other_value(other) end |
#<=(other) ⇒ Object
60 61 62 |
# File 'lib/cms_scanner/finders/confidence.rb', line 60 def <=(other) @value <= other_value(other) end |
#<=>(other) ⇒ Object
75 76 77 |
# File 'lib/cms_scanner/finders/confidence.rb', line 75 def <=>(other) @value <=> other_value(other) end |
#==(other) ⇒ Object
45 46 47 |
# File 'lib/cms_scanner/finders/confidence.rb', line 45 def ==(other) @value == other_value(other) end |
#>(other) ⇒ Object
65 66 67 |
# File 'lib/cms_scanner/finders/confidence.rb', line 65 def >(other) @value > other_value(other) end |
#>=(other) ⇒ Object
70 71 72 |
# File 'lib/cms_scanner/finders/confidence.rb', line 70 def >=(other) @value >= other_value(other) end |
#eql?(other) ⇒ Boolean
50 51 52 |
# File 'lib/cms_scanner/finders/confidence.rb', line 50 def eql?(other) @value.eql?(other_value(other)) end |
#other_value(other) ⇒ Object
40 41 42 |
# File 'lib/cms_scanner/finders/confidence.rb', line 40 def other_value(other) other.is_a?(Confidence) ? other.value : other end |
#to_json ⇒ Object
35 36 37 |
# File 'lib/cms_scanner/finders/confidence.rb', line 35 def to_json @value.to_json end |
#to_s ⇒ Object
Convenient Methods
:nocov:
31 32 33 |
# File 'lib/cms_scanner/finders/confidence.rb', line 31 def to_s @value.to_s end |