Class: Float

Inherits:
Object
  • Object
show all
Defined in:
lib/splib/Float.rb

Overview

While not a big fan of monkeypatching, I want to be lazy getting to this

Instance Method Summary collapse

Instance Method Details

#within_delta?(args = {}) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
# File 'lib/splib/Float.rb', line 5

def within_delta?(args={})
    raise ArgumentError.new('Missing required argument: :expected') unless args[:expected]
    raise ArgumentError.new('Missing required argument: :delta') unless args[:delta]
    e = args[:expected].to_f
    d = args[:delta].to_f
    self.between?(e-d, e+d)
end