Class: SPARQL::Algebra::Operator::Equal

Inherits:
Compare show all
Defined in:
lib/sparql/algebra/operator/equal.rb

Overview

The SPARQL relational = (equal) comparison operator.

Examples:

(= ?x ?y)

See Also:

Direct Known Subclasses

NotEqual

Constant Summary

NAME =
=

Constants inherited from Binary

Binary::ARITY

Constants inherited from SPARQL::Algebra::Operator

ARITY

Instance Attribute Summary

Attributes inherited from SPARQL::Algebra::Operator

#operands, #options

Instance Method Summary (collapse)

Methods included from Evaluatable

#evaluate, #memoize

Methods inherited from Binary

#initialize

Methods inherited from SPARQL::Algebra::Operator

arity, base_uri, #base_uri, base_uri=, #boolean, #constant?, #eql?, #evaluatable?, evaluate, #executable?, for, #initialize, #inspect, #operand, #optimize, prefixes, #prefixes, prefixes=, #to_sse, #to_sxp, #variable?

Methods included from Expression

cast, #constant?, #evaluate, for, new, open, #optimize, parse, #to_sse, #variable?

Constructor Details

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

Instance Method Details

- (RDF::Literal::Boolean) apply(term1, term2)

Returns true if the operands are equal; returns false otherwise.

Parameters:

Returns:

  • (RDF::Literal::Boolean)

    true or false

Raises:

  • (TypeError)

    if either operand is not an RDF term or operands are not comperable

See Also:

  • SPARQL::Algebra::Operator::Equal.{RDF{RDF::Term{RDF::Term#==}


25
26
27
28
29
# File 'lib/sparql/algebra/operator/equal.rb', line 25

def apply(term1, term2)
  term1 = term1.dup.extend(RDF::TypeCheck)
  term2 = term2.dup.extend(RDF::TypeCheck)
  RDF::Literal(term1 == term2)
end