Sha256: dd4882810029e47de5f677dd4743fdbf13ecdb1b03d410f56cc98ca2478cb6a3
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
Contents
module SPARQL; module Algebra class Operator ## # The SPARQL `isLiteral` operator. # # @example # (prefix ((xsd: <http://www.w3.org/2001/XMLSchema#>) # (: <http://example.org/things#>)) # (project (?x ?v) # (filter (isLiteral ?v) # (bgp (triple ?x :p ?v))))) # # @see https://www.w3.org/TR/sparql11-query/#func-isLiteral class IsLiteral < Operator::Unary include Evaluatable NAME = :isLiteral ## # Returns `true` if the operand is an `RDF::Literal`, `false` # otherwise. # # @param [RDF::Term] term # an RDF term # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if the operand is not an RDF term def apply(term) case term when RDF::Literal then RDF::Literal::TRUE when RDF::Term then RDF::Literal::FALSE else raise TypeError, "expected an RDF::Term, but got #{term.inspect}" end end end # IsLiteral end # Operator end; end # SPARQL::Algebra
Version data entries
5 entries across 5 versions & 1 rubygems