class SPARQL::Algebra::Operator::Str
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)))))
Constants
- NAME
Public Instance Methods
apply(term, **options)
click to toggle source
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
# File lib/sparql/algebra/operator/str.rb, line 26 def apply(term, **options) 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