Sha256: 0424e29a608588244919a0ba2f3ad06ceca759308128ffb7c7c3d710b41ddcdf
Contents?: true
Size: 1.21 KB
Versions: 12
Compression:
Stored size: 1.21 KB
Contents
module SPARQL; module Algebra class Operator ## # 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 http://www.w3.org/TR/rdf-sparql-query/#func-datatype class Datatype < Operator::Unary include Evaluatable NAME = :datatype ## # 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 def apply(literal) case literal when RDF::Literal then literal.datatype else raise TypeError, "expected an RDF::Literal, but got #{literal.inspect}" end end end # Datatype end # Operator end; end # SPARQL::Algebra
Version data entries
12 entries across 12 versions & 1 rubygems