Module: Hellobase::CoreExt::DivideByZeroFix

Defined in:
lib/hellobase/core_ext/divide_by_zero_fix.rb

Instance Method Summary collapse

Instance Method Details

#/(arg) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/hellobase/core_ext/divide_by_zero_fix.rb', line 4

def /(arg)
  begin
    result = super
    result == BigDecimal::INFINITY || result == -BigDecimal::INFINITY ? BigDecimal::NAN : result
  rescue ZeroDivisionError
    BigDecimal::NAN
  end
end