Class: SPARQL::Algebra::Operator::EncodeForURI
- Includes:
- Evaluatable
- Defined in:
- lib/sparql/algebra/operator/encode_for_uri.rb
Overview
The SPARQL logical abs operator.
[121] BuiltInCall ::= ... | 'ENCODE_FOR_URI' '(' Expression ')'
Constant Summary collapse
- NAME =
:encode_for_uri
Instance Method Summary collapse
-
#apply(operand, **options) ⇒ RDF::Literal
The
ENCODE_FOR_URIfunction corresponds to the XPath fn:encode-for-uri function. -
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
Methods included from Evaluatable
#evaluate, #memoize, #replace_aggregate!, #replace_vars!
Instance Method Details
#apply(operand, **options) ⇒ RDF::Literal
The ENCODE_FOR_URI function corresponds to the XPath fn:encode-for-uri function. It returns a simple literal with the lexical form obtained from the lexical form of its input after translating reserved characters according to the fn:encode-for-uri function.
41 42 43 44 45 46 |
# File 'lib/sparql/algebra/operator/encode_for_uri.rb', line 41 def apply(operand, **) case operand when RDF::Literal then RDF::Literal(CGI.escape(operand.to_s)) else raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" end end |
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
53 54 55 |
# File 'lib/sparql/algebra/operator/encode_for_uri.rb', line 53 def to_sparql(**) "ENCODE_FOR_URI(#{operands.last.to_sparql(**)})" end |