Class: SPARQL::Algebra::Operator::Datatype
- Inherits:
-
Unary
- Object
- SPARQL::Algebra::Operator
- Unary
- SPARQL::Algebra::Operator::Datatype
- Defined in:
- lib/sparql/algebra/operator/datatype.rb
Overview
The SPARQL datatype operator.
Constant Summary
- NAME =
:datatype
Constants inherited from Unary
Instance Method Summary (collapse)
-
- (RDF::URI) evaluate(solution)
Returns the datatype IRI of the operand.
Methods inherited from Unary
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::URI) evaluate(solution)
Returns the datatype IRI of the operand.
If the operand is a simple literal, returns a datatype of
xsd:string.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sparql/algebra/operator/datatype.rb', line 19 def evaluate(solution) case literal = operand(0, solution) when RDF::Literal then case when literal.typed? then RDF::URI(literal.datatype) when literal.simple? then RDF::XSD.string else raise TypeError, "expected a typed or simple RDF::Literal, but got #{literal.inspect}" end else raise TypeError, "expected an RDF::Literal, but got #{literal.inspect}" end end |