Class: SPARQL::Algebra::Operator::Bound
- Includes:
- Evaluatable
- Defined in:
- lib/sparql/algebra/operator/bound.rb
Overview
The SPARQL bound operator.
[121] BuiltInCall ::= ... | 'BOUND' '(' Var ')'
Constant Summary collapse
- NAME =
:bound
Instance Method Summary collapse
-
#evaluate(bindings, **options) ⇒ RDF::Literal::Boolean
Returns
trueifvaris 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!
Constructor Details
#initialize(var, **options) ⇒ Bound
Initializes a new operator instance.
40 41 42 |
# File '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 '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 'lib/sparql/algebra/operator/bound.rb', line 67 def to_sparql(**) "bound(" + operands.first.to_sparql(**) + ")" end |