Sha256: 8a882464161ce8ccba66b6262292991ad2614d33b3ef6569619055be282f7d90

Contents?: true

Size: 836 Bytes

Versions: 20

Compression:

Stored size: 836 Bytes

Contents

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

      NAME = [:+, :plus]

      ##
      # Returns the operand with its sign unchanged.
      #
      # @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 # Plus
  end # Operator
end; end # SPARQL::Algebra

Version data entries

20 entries across 20 versions & 1 rubygems

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