Module: Trxl::MultitiveOp0

Defined in:
lib/trxl/trxl_grammar.rb

Instance Method Summary collapse

Instance Method Details

#apply(a, b) ⇒ Object



3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
# File 'lib/trxl/trxl_grammar.rb', line 3459

def apply(a, b)
  begin
    result = super
    if result == 1.0 / 0 || (result.respond_to?(:nan?) && result.nan?)
      raise Trxl::DivisionByZeroError, "Division by zero: '#{a} / #{b}'"
    end
    result
  rescue ZeroDivisionError
    raise Trxl::DivisionByZeroError, "Division by zero: '#{a} / #{b}'"
  end
end