Class: Gobstones::Lang::Div

Inherits:
ArithmeticExpression show all
Defined in:
lib/gobstones/lang/expressions/arithmetic_expressions.rb

Instance Attribute Summary

Attributes inherited from TwoArgExpression

#left_expr, #right_expr

Instance Method Summary collapse

Methods inherited from ArithmeticExpression

numbers

Methods inherited from TwoArgExpression

#equality_attributes, evaluates_with, #initialize

Methods inherited from Expression

#is_function_call?

Methods included from EqualityDefinition

#==, #equality_attributes

Constructor Details

This class inherits a constructor from Gobstones::Lang::TwoArgExpression

Instance Method Details

#evaluate(context) ⇒ Object



27
28
29
30
31
# File 'lib/gobstones/lang/expressions/arithmetic_expressions.rb', line 27

def evaluate(context)
  left_expr.evaluate(context) / right_expr.evaluate(context)
rescue ZeroDivisionError
  raise Runner::GobstonesRuntimeError, 'zero division'
end