class SPARQL::Algebra::Operator::Multiply

The SPARQL numeric `multiply` operator.

@example

(* ?x ?y)
(multiply ?x ?y)

@see www.w3.org/TR/xpath-functions/#func-numeric-multiply

Constants

NAME

Public Instance Methods

apply(left, right, **options) click to toggle source

Returns the arithmetic product of the operands.

@param [RDF::Literal::Numeric] left

a numeric literal

@param [RDF::Literal::Numeric] right

a numeric literal

@return [RDF::Literal::Numeric] @raise [TypeError] if either operand is not a numeric literal

# File lib/sparql/algebra/operator/multiply.rb, line 25
def apply(left, right, **options)
  case
    when left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric)
      left * right
    else raise TypeError, "expected two RDF::Literal::Numeric operands, but got #{left.inspect} and #{right.inspect}"
  end
end