lib/sparql/algebra/operator/asc.rb in sparql-3.1.8 vs lib/sparql/algebra/operator/asc.rb in sparql-3.2.0
- old
+ new
@@ -1,11 +1,19 @@
module SPARQL; module Algebra
class Operator
##
# The SPARQL ascending sort operator.
#
- # @example
+ # [24] OrderCondition ::= ( ( 'ASC' | 'DESC' ) BrackettedExpression ) | ( Constraint | Var )
+ #
+ # @example SPARQL Query
+ # PREFIX foaf: <http://xmlns.com/foaf/0.1/>
+ # SELECT ?name
+ # WHERE { ?x foaf:name ?name }
+ # ORDER BY ASC(?name)
+ #
+ # @example SSE
# (prefix ((foaf: <http://xmlns.com/foaf/0.1/>))
# (project (?name)
# (order ((asc ?name))
# (bgp (triple ?x foaf:name ?name)))))
#
@@ -24,9 +32,20 @@
# @param [Hash{Symbol => Object}] options ({})
# options passed from query
# @return [RDF::Term]
def evaluate(bindings, **options)
operand(0).evaluate(bindings, depth: options[:depth].to_i + 1, **options)
+ end
+
+ ##
+ #
+ # Returns a partial SPARQL grammar for this operator.
+ #
+ # Provides order to descendant query.
+ #
+ # @return [String]
+ def to_sparql(**options)
+ "ASC(#{operands.last.to_sparql(**options)})"
end
end # Asc
end # Operator
end; end # SPARQL::Algebra