Ruby Simple calculator

Simple calculator

#!/usr/local/bin/ruby

def calculate(opnd1, op, opnd2)
   string = opnd1.to_s + op + opnd2.to_s
      # operator is assumed to be a string; make one big
      # string of it and the tow operands
   eval(string)  # evaluate and return a value
end