class Approximately::DeltaFloat
This object can be used for float comparisons. When it is instantiaded with a float and a delta it will respond to <=>(another_float) and will return equality if the float it’s being compared to is within the delta
Public Instance Methods
<=>(another)
click to toggle source
# File lib/approximately.rb, line 17 def <=>(another) d = (to_f - another.to_f).abs return 0 if d < delta float <=> another.to_f end
inspect()
click to toggle source
# File lib/approximately.rb, line 23 def inspect "~%0.8f" % to_f end
to_f()
click to toggle source
# File lib/approximately.rb, line 13 def to_f float.to_f end
to_s()
click to toggle source
# File lib/approximately.rb, line 27 def to_s inspect end