Sha256: 499d19994d0d0c364fdbb331878b33f7bb439c4fb614daf1b86980e7d667b179

Contents?: true

Size: 1.03 KB

Versions: 17

Compression:

Stored size: 1.03 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL logical `round` operator.
    #
    # @example
    #   (round ?x)
    #
    # @see http://www.w3.org/TR/sparql11-query/#func-round
    # @see http://www.w3.org/TR/xpath-functions/#func-round
    class Round < Operator::Unary
      include Evaluatable

      NAME = [:round]

      ##
      # Returns the number with no fractional part that is closest to the argument. If there are two such numbers, then the one that is closest to positive infinity is returned. An error is raised if arg is not a numeric value.
      #
      # @param  [RDF::Literal] operand
      #   the operand
      # @return [RDF::Literal] literal of same type
      # @raise  [TypeError] if the operand is not a numeric value
      def apply(operand)
        case operand
          when RDF::Literal::Numeric then operand.round
          else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}"
        end
      end
    end # Round
  end # Operator
end; end # SPARQL::Algebra

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sparql-1.99.1 lib/sparql/algebra/operator/round.rb
sparql-1.1.9.1 lib/sparql/algebra/operator/round.rb
sparql-1.99.0 lib/sparql/algebra/operator/round.rb
sparql-1.1.9 lib/sparql/algebra/operator/round.rb
sparql-1.1.8 lib/sparql/algebra/operator/round.rb
sparql-1.1.7 lib/sparql/algebra/operator/round.rb
sparql-1.1.6 lib/sparql/algebra/operator/round.rb
sparql-1.1.5 lib/sparql/algebra/operator/round.rb
sparql-1.1.4 lib/sparql/algebra/operator/round.rb
sparql-1.1.3 lib/sparql/algebra/operator/round.rb
sparql-1.1.2.1 lib/sparql/algebra/operator/round.rb
sparql-1.1.2 lib/sparql/algebra/operator/round.rb
sparql-1.1.1 lib/sparql/algebra/operator/round.rb
sparql-1.1.0 lib/sparql/algebra/operator/round.rb
sparql-1.1.0p0 lib/sparql/algebra/operator/round.rb
sparql-1.0.8 lib/sparql/algebra/operator/round.rb
sparql-1.0.7 lib/sparql/algebra/operator/round.rb