Sha256: 02e4c6fdc0f8281fb48ebf1d2806b8d7aadcac7f2423a8b88da999c6b26b7f95

Contents?: true

Size: 923 Bytes

Versions: 11

Compression:

Stored size: 923 Bytes

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL logical `rand` operator.
    #
    # Returns a pseudo-random number between 0 (inclusive) and 1.0e0 (exclusive). Different numbers can be produced every time this function is invoked. Numbers should be produced with approximately equal probability.
    #
    # @example
    #   (rand)
    #
    # @see http://www.w3.org/TR/sparql11-query/#idp2130040
    class Rand < Operator::Nullary
      include Evaluatable

      NAME = :rand

      ##
      # Returns a pseudo-random number between 0 (inclusive) and 1.0e0 (exclusive). Different numbers can be produced every time this function is invoked. Numbers should be produced with approximately equal probability.
      #
      # @return [RDF::Literal::Double] random value
      def apply
        RDF::Literal::Double.new(Random.rand)
      end
    end # Rand
  end # Operator
end; end # SPARQL::Algebra

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sparql-3.1.0 lib/sparql/algebra/operator/rand.rb
sparql-3.0.2 lib/sparql/algebra/operator/rand.rb
sparql-3.0.1 lib/sparql/algebra/operator/rand.rb
sparql-3.0.0 lib/sparql/algebra/operator/rand.rb
sparql-2.2.2 lib/sparql/algebra/operator/rand.rb
sparql-2.2.1 lib/sparql/algebra/operator/rand.rb
sparql-2.2.0 lib/sparql/algebra/operator/rand.rb
sparql-2.1.0 lib/sparql/algebra/operator/rand.rb
sparql-2.0.0 lib/sparql/algebra/operator/rand.rb
sparql-2.0.0.beta2 lib/sparql/algebra/operator/rand.rb
sparql-2.0.0.beta1 lib/sparql/algebra/operator/rand.rb