class IdentityParade::Matchers::NumericMatcher

This matcher checks the similarity of two numerics.

Public Instance Methods

floats() click to toggle source
# File lib/identity_parade/matchers/numeric_matcher.rb, line 20
def floats
  [left.to_f, right.to_f]
end
max() click to toggle source
# File lib/identity_parade/matchers/numeric_matcher.rb, line 12
def max
  floats.max
end
min() click to toggle source
# File lib/identity_parade/matchers/numeric_matcher.rb, line 16
def min
  floats.min
end
score() click to toggle source
# 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