Class: SPARQL::Algebra::Operator::Bound

Inherits:
Unary show all
Defined in:
lib/sparql/algebra/operator/bound.rb

Overview

The SPARQL bound operator.

See Also:

Constant Summary

NAME =
:bound

Constants inherited from Unary

ARITY

Instance Method Summary (collapse)

Methods inherited from Unary

#initialize

Methods inherited from SPARQL::Algebra::Operator

#boolean, #constant?, evaluate, #initialize, #operand, #to_sse, #variable?

Constructor Details

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

Instance Method Details

- (RDF::Literal::Boolean) evaluate(solution)

Returns true if the operand is a variable that is bound to a value in the given solution, false otherwise.

Parameters:

  • (RDF::Query::Solution) solution

Returns:

  • (RDF::Literal::Boolean)

    true or false

Raises:

  • (TypeError)

    if the operand is not an RDF::Query::Variable



17
18
19
20
21
22
23
# File 'lib/sparql/algebra/operator/bound.rb', line 17

def evaluate(solution)
  case var = operands.first
    when RDF::Query::Variable, Symbol
      RDF::Literal(solution.bound?(var))
    else raise TypeError, "expected an RDF::Query::Variable, but got #{var.inspect}"
  end
end