Sha256: 2cca558b0f53b79adc0096f5a85721b3b670dafbe8a2dde42d9350f49deed6a7

Contents?: true

Size: 850 Bytes

Versions: 26

Compression:

Stored size: 850 Bytes

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL numeric unary `-` (negation) operator.
    #
    # @example
    #   (- ?x)
    #   (negate ?x)
    #
    # @see http://www.w3.org/TR/xpath-functions/#func-numeric-unary-minus
    class Negate < Operator::Unary
      include Evaluatable

      NAME = [:-, :negate]

      ##
      # Returns the operand with its sign reversed.
      #
      # @param  [RDF::Literal::Numeric] term
      #   a numeric literal
      # @return [RDF::Literal::Numeric]
      # @raise  [TypeError] if the operand is not a numeric literal
      def apply(term)
        case term
          when RDF::Literal::Numeric then -term
          else raise TypeError, "expected an RDF::Literal::Numeric, but got #{term.inspect}"
        end
      end
    end # Negate
  end # Operator
end; end # SPARQL::Algebra

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
sparql-3.1.0 lib/sparql/algebra/operator/negate.rb
sparql-3.0.2 lib/sparql/algebra/operator/negate.rb
sparql-3.0.1 lib/sparql/algebra/operator/negate.rb
sparql-3.0.0 lib/sparql/algebra/operator/negate.rb
sparql-2.2.2 lib/sparql/algebra/operator/negate.rb
sparql-2.2.1 lib/sparql/algebra/operator/negate.rb
sparql-2.2.0 lib/sparql/algebra/operator/negate.rb
sparql-2.1.0 lib/sparql/algebra/operator/negate.rb
sparql-2.0.0 lib/sparql/algebra/operator/negate.rb
sparql-2.0.0.beta2 lib/sparql/algebra/operator/negate.rb
sparql-1.99.1 lib/sparql/algebra/operator/negate.rb
sparql-2.0.0.beta1 lib/sparql/algebra/operator/negate.rb
sparql-1.1.9.1 lib/sparql/algebra/operator/negate.rb
sparql-1.99.0 lib/sparql/algebra/operator/negate.rb
sparql-1.1.9 lib/sparql/algebra/operator/negate.rb
sparql-1.1.8 lib/sparql/algebra/operator/negate.rb
sparql-1.1.7 lib/sparql/algebra/operator/negate.rb
sparql-1.1.6 lib/sparql/algebra/operator/negate.rb
sparql-1.1.5 lib/sparql/algebra/operator/negate.rb
sparql-1.1.4 lib/sparql/algebra/operator/negate.rb