Class: Gloo::Expr::OpMult

Inherits:
Core::Op show all
Defined in:
lib/gloo/expr/op_mult.rb

Constant Summary collapse

SYMBOL =
'*'.freeze

Instance Method Summary collapse

Methods inherited from Core::Op

create_op, default_op, op?

Instance Method Details

#perform(left, right) ⇒ Object

Perform the operation and return the result.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gloo/expr/op_mult.rb', line 16

def perform( left, right )
  if ( left.is_a? Integer ) && ( right.is_a? Integer )
    return left * right
  end
  
  if (left.is_a? Numeric) && (right.is_a? Numeric)
    return left * right
  end

  return left * right.to_i if left.is_a? Integer

  return left * right.to_f if left.is_a? Numeric
end