Class: SPARQL::Algebra::Operator::Bound
- Inherits:
-
Unary
- Object
- SPARQL::Algebra::Operator
- Unary
- SPARQL::Algebra::Operator::Bound
- Includes:
- Evaluatable
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/bound.rb
Overview
The SPARQL bound
operator.
[121] BuiltInCall ::= ... | 'BOUND' '(' Var ')'
Constant Summary collapse
- NAME =
:bound
Constants inherited from Unary
Constants inherited from SPARQL::Algebra::Operator
Constants included from Expression
Constants included from RDF::Util::Logger
Instance Attribute Summary
Attributes inherited from SPARQL::Algebra::Operator
Instance Method Summary collapse
-
#evaluate(bindings, **options) ⇒ RDF::Literal::Boolean
Returns
true
ifvar
is bound to a value. -
#initialize(var, **options) ⇒ Bound
constructor
Initializes a new operator instance.
-
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
Methods included from Evaluatable
#apply, #memoize, #replace_aggregate!, #replace_vars!
Methods inherited from SPARQL::Algebra::Operator
#aggregate?, arity, base_uri, #base_uri, base_uri=, #bind, #boolean, #constant?, #deep_dup, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #formulae, #inspect, #mergable?, #ndvars, #node?, #operand, #optimize, #optimize!, #parent, #parent=, prefixes, #prefixes, prefixes=, #rewrite, #to_binary, to_sparql, #to_sxp, #to_sxp_bin, #validate!, #variable?, #variables, #vars
Methods included from Expression
cast, #constant?, extension, extension?, extensions, for, #invalid?, new, #node?, open, #optimize, #optimize!, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?
Methods included from RDF::Util::Logger
#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger
Constructor Details
#initialize(var, **options) ⇒ Bound
Initializes a new operator instance.
40 41 42 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/bound.rb', line 40 def initialize(var, **) super end |
Instance Method Details
#evaluate(bindings, **options) ⇒ RDF::Literal::Boolean
Returns true
if var
is bound to a value. Returns false otherwise. Variables with the value NaN or INF are considered bound.
53 54 55 56 57 58 59 60 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/bound.rb', line 53 def evaluate(bindings, **) case var = operand when Variable bindings.respond_to?(:bound?) && bindings.bound?(var) ? RDF::Literal::TRUE : RDF::Literal::FALSE else raise TypeError, "expected an RDF::Query::Variable, but got #{var.inspect}" end end |
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
67 68 69 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/bound.rb', line 67 def to_sparql(**) "bound(" + operands.first.to_sparql(**) + ")" end |