Class: SPARQL::Algebra::Operator::Rand

Inherits:
Nullary show all
Includes:
Evaluatable
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/sparql-683a29666c28/lib/sparql/algebra/operator/rand.rb

Overview

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.

Constant Summary collapse

NAME =
:rand

Constants inherited from Nullary

Nullary::ARITY

Constants inherited from SPARQL::Algebra::Operator

ARITY, IsURI, URI

Instance Attribute Summary

Attributes inherited from SPARQL::Algebra::Operator

#operands

Instance Method Summary collapse

Methods included from Evaluatable

#evaluate, #memoize, #replace_aggregate!, #replace_vars!

Methods inherited from Nullary

#initialize

Methods inherited from SPARQL::Algebra::Operator

#aggregate?, arity, #base_uri, base_uri, base_uri=, #boolean, #constant?, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #initialize, #inspect, #ndvars, #node?, #operand, #optimize, #parent, #parent=, prefixes, #prefixes, prefixes=, #rewrite, #to_binary, #to_sxp, #to_sxp_bin, #validate!, #variable?, #vars

Methods included from Expression

cast, #constant?, #evaluate, extension, extensions, for, #invalid?, new, #node?, open, #optimize, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?

Constructor Details

This class inherits a constructor from SPARQL::Algebra::Operator::Nullary

Instance Method Details

#applyRDF::Literal::Double

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.

Returns:



21
22
23
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-683a29666c28/lib/sparql/algebra/operator/rand.rb', line 21

def apply
  RDF::Literal::Double.new(Random.rand)
end