Sha256: 7bdcff0a6a712431d5b328f25c18f13f075861f366cd26a05bb1be325719372a

Contents?: true

Size: 1.01 KB

Versions: 42

Compression:

Stored size: 1.01 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL numeric `multiply` operator.
    #
    # @example
    #   (* ?x ?y)
    #   (multiply ?x ?y)
    #
    # @see http://www.w3.org/TR/xpath-functions/#func-numeric-multiply
    class Multiply < Operator::Binary
      include Evaluatable

      NAME = [:*, :multiply]

      ##
      # 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
      def apply(left, right)
        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
    end # Multiply
  end # Operator
end; end # SPARQL::Algebra

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
sparql-1.1.3 lib/sparql/algebra/operator/multiply.rb
sparql-1.1.2.1 lib/sparql/algebra/operator/multiply.rb
sparql-1.1.2 lib/sparql/algebra/operator/multiply.rb
sparql-1.1.1 lib/sparql/algebra/operator/multiply.rb
sparql-1.1.0 lib/sparql/algebra/operator/multiply.rb
sparql-1.1.0p0 lib/sparql/algebra/operator/multiply.rb
sparql-1.0.8 lib/sparql/algebra/operator/multiply.rb
sparql-1.0.7 lib/sparql/algebra/operator/multiply.rb
sparql-1.0.6 lib/sparql/algebra/operator/multiply.rb
sparql-1.0.5 lib/sparql/algebra/operator/multiply.rb
sparql-1.0.4 lib/sparql/algebra/operator/multiply.rb
sparql-1.0.3 lib/sparql/algebra/operator/multiply.rb
sparql-1.0.2 lib/sparql/algebra/operator/multiply.rb
sparql-1.0.1 lib/sparql/algebra/operator/multiply.rb
sparql-1.0.0 lib/sparql/algebra/operator/multiply.rb
sparql-0.3.3 lib/sparql/algebra/operator/multiply.rb
sparql-0.3.2 lib/sparql/algebra/operator/multiply.rb
sparql-0.3.1 lib/sparql/algebra/operator/multiply.rb
sparql-0.3.0 lib/sparql/algebra/operator/multiply.rb
sparql-0.1.1 lib/sparql/algebra/operator/multiply.rb