Class: IdentityParade::Matchers::NumericMatcher
Overview
This matcher checks the similarity of two numerics.
Instance Attribute Summary
#left, #right
Instance Method Summary
collapse
#initialize
Instance Method Details
#floats ⇒ Object
20
21
22
|
# File 'lib/identity_parade/matchers/numeric_matcher.rb', line 20
def floats
[left.to_f, right.to_f]
end
|
#max ⇒ Object
12
13
14
|
# File 'lib/identity_parade/matchers/numeric_matcher.rb', line 12
def max
floats.max
end
|
#min ⇒ Object
16
17
18
|
# File 'lib/identity_parade/matchers/numeric_matcher.rb', line 16
def min
floats.min
end
|
#score ⇒ Object
5
6
7
8
9
10
|
# File 'lib/identity_parade/matchers/numeric_matcher.rb', line 5
def score
return 1 if max == min
return 0 if max.zero?
min / max
end
|