class SPARQL::Algebra::Operator::Bound
The SPARQL
`bound` operator.
@example
(prefix ((: <http://example.org/ns#>)) (project (?a ?c) (filter (! (bound ?e)) (leftjoin (bgp (triple ?a :b ?c)) (bgp (triple ?c :d ?e))))))
Constants
- NAME
Public Class Methods
new(var, **options)
click to toggle source
Initializes a new operator instance.
@param [RDF::Query::Variable] var
a variable
@param [Hash{Symbol => Object}] options
any additional options (see {Operator#initialize})
@raise [TypeError] if any operand is invalid
Calls superclass method
SPARQL::Algebra::Operator::Unary::new
# File lib/sparql/algebra/operator/bound.rb, line 28 def initialize(var, **options) super end
Public Instance Methods
evaluate(bindings, **options)
click to toggle source
Returns `true` if `var` is bound to a value. Returns false otherwise. Variables with the value NaN or INF are considered bound.
@param [RDF::Query::Solution] bindings
a query solution containing zero or more variable bindings
@param [Hash{Symbol => Object}] options ({})
options passed from query
@return [RDF::Literal::Boolean] `true` or `false` @raise [TypeError] if the operand is not a variable
# File lib/sparql/algebra/operator/bound.rb, line 41 def evaluate(bindings, **options) 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