module TfPoint::Calculate
Public Instance Methods
devision_operation(expa, expb, numa, numb)
click to toggle source
/
# File lib/24point/calculate.rb, line 26 def devision_operation(expa, expb, numa, numb) return "", 0 if !numa.is_a?(Fixnum) || !numb.is_a?(Fixnum) exp = expa + '/' + expb return exp, (numa / numb) end
multi_operation(expa, expb, numa, numb)
click to toggle source
*
# File lib/24point/calculate.rb, line 19 def multi_operation(expa, expb, numa, numb) return "", 0 if !numa.is_a?(Fixnum) || !numb.is_a?(Fixnum) exp = (expa > expb) ? expa + '*' + expb : expb + '*' + expa return exp, (numa * numb) end
plus_operation(expa, expb, n, numa, numb)
click to toggle source
+ 排序,大的在前,小的在后,如果是最后一次(n=2),不加括号
# File lib/24point/calculate.rb, line 4 def plus_operation(expa, expb, n, numa, numb) return "", 0 if !numa.is_a?(Fixnum) || !numb.is_a?(Fixnum) expa, expb = expb, expa if expa.is_num? && expb.is_num? && expa < expb exp = (n == 2) ? expa + '+' + expb : '(' + expa + '+' + expb + ')' return exp, (numa + numb) end
sub_operation(expa, expb, n, numa, numb)
click to toggle source
-
# File lib/24point/calculate.rb, line 12 def sub_operation(expa, expb, n, numa, numb) return "", 0 if !numa.is_a?(Fixnum) || !numb.is_a?(Fixnum) exp = (n == 2) ? expa + '-' + expb : '(' + expa + '-' + expb + ')' return exp, (numa - numb) end