Sha256: 06c45f75cec87e74ad6dbbb0d83f8f06adbc1d2dc1d6d88fea7353a34da88309
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
module SPARQL; module Algebra class Operator ## # The SPARQL `str` operator. # # @example # (prefix ((xsd: <http://www.w3.org/2001/XMLSchema#>) # (: <http://example.org/things#>)) # (project (?x ?v) # (filter (= (str ?v) "1") # (bgp (triple ?x :p ?v))))) # # @see https://www.w3.org/TR/sparql11-query/#func-str class Str < Operator::Unary include Evaluatable NAME = :str ## # Returns the string form of the operand. # # @param [RDF::Literal, RDF::URI] term # a literal or IRI # @return [RDF::Literal] a simple literal # @raise [TypeError] if the operand is not a literal or IRI def apply(term) case term when RDF::Literal then RDF::Literal(term.value) when RDF::URI then RDF::Literal(term.to_s) else raise TypeError, "expected an RDF::Literal or RDF::URI, but got #{term.inspect}" end end end # Str end # Operator end; end # SPARQL::Algebra
Version data entries
5 entries across 5 versions & 1 rubygems