Module: FormulaDSL::BinaryExpressionFactory

Defined in:
lib/formula_dsl/binary_expression_factory.rb

Class Method Summary collapse

Class Method Details

.new(operator) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/formula_dsl/binary_expression_factory.rb', line 9

def self.new(operator)
  operation = case operator
              when :+ then ::FormulaDSL::BinaryOperations::ADDITION
              when :- then ::FormulaDSL::BinaryOperations::SUBTRACTION
              when :* then ::FormulaDSL::BinaryOperations::MULTIPLICATION
              when :/ then ::FormulaDSL::BinaryOperations::DIVISION
              else raise MissingBinaryOperationError, "Sorry, but we don't have a implementation for the operator ( #{operator} )."
              end

  operation
end