Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/evelpidon_core_ext/numeric.rb

Instance Method Summary collapse

Instance Method Details

#within_delta?(expected, delta) ⇒ Boolean

Checks whether self is almost equal to another number within a specified precision. Taken from stackoverflow.com/a/239314/75246

Returns:

  • (Boolean)


4
5
6
# File 'lib/evelpidon_core_ext/numeric.rb', line 4

def within_delta?(expected, delta)
  (expected - self).abs <= delta
end