class SPARQL::Algebra::Operator::Datatype

The SPARQL `datatype` operator.

@example

(prefix ((xsd: <http://www.w3.org/2001/XMLSchema#>)
         (rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
         (: <http://example.org/>))
  (project (?s)
    (filter (= (datatype (xsd:double ?v)) xsd:double)
      (bgp (triple ?s :p ?v)))))

@see www.w3.org/TR/sparql11-query/#func-datatype

Constants

NAME

Public Instance Methods

apply(literal, **options) click to toggle source

Returns the datatype IRI of the operand.

If the operand is a simple literal, returns a datatype of `xsd:string`.

@param [RDF::Literal] literal

a typed or simple literal

@return [RDF::URI] the datatype IRI, or `xsd:string` for simple literals @raise [TypeError] if the operand is not a typed or simple literal

# File lib/sparql/algebra/operator/datatype.rb, line 30
def apply(literal, **options)
  case literal
    when RDF::Literal then literal.datatype
    else raise TypeError, "expected an RDF::Literal, but got #{literal.inspect}"
  end
end