Class: SPARQL::Algebra::Operator::SameTerm
- Inherits:
-
Binary
- Object
- SPARQL::Algebra::Operator
- Binary
- SPARQL::Algebra::Operator::SameTerm
- Includes:
- Evaluatable
- Defined in:
- lib/sparql/algebra/operator/same_term.rb
Overview
The SPARQL sameTerm
operator.
Constant Summary
- NAME =
:sameTerm
Constants inherited from Binary
Constants inherited from SPARQL::Algebra::Operator
Instance Attribute Summary
Attributes inherited from SPARQL::Algebra::Operator
Instance Method Summary collapse
-
#apply(term1, term2) ⇒ RDF::Literal::Boolean
Returns
true
if the operands are the same RDF term; returnsfalse
otherwise. -
#optimize ⇒ SPARQL::Algebra::Expression
Returns an optimized version of this expression.
Methods included from Evaluatable
Methods inherited from Binary
Methods inherited from SPARQL::Algebra::Operator
arity, #base_uri, base_uri, base_uri=, #boolean, #constant?, #eql?, #evaluatable?, evaluate, #executable?, for, #initialize, #inspect, #operand, #prefixes, prefixes, prefixes=, #to_sse, #to_sxp, #variable?
Methods included from Expression
cast, #constant?, #evaluate, for, new, open, parse, #to_sse, #variable?
Constructor Details
This class inherits a constructor from SPARQL::Algebra::Operator::Binary
Instance Method Details
#apply(term1, term2) ⇒ RDF::Literal::Boolean
Returns true
if the operands are the same RDF term; returns
false
otherwise.
29 30 31 |
# File 'lib/sparql/algebra/operator/same_term.rb', line 29 def apply(term1, term2) RDF::Literal(term1.eql?(term2)) end |
#optimize ⇒ SPARQL::Algebra::Expression
Returns an optimized version of this expression.
37 38 39 40 41 42 43 |
# File 'lib/sparql/algebra/operator/same_term.rb', line 37 def optimize if operand(0).is_a?(Variable) && operand(0).eql?(operand(1)) RDF::Literal::TRUE else super # @see Operator#optimize end end |