Sha256: f14288f974f8d316e2ae19b171b3524c42fe06598b76899b7faea0bbab5dbbfe

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL Property Path `path*` (ZeroOrMorePath) operator.
    #
    # @example
    #   (path* :p)
    #
    # @see https://www.w3.org/TR/sparql11-query/#defn_evalPP_ZeroOrMorePath
    class PathStar < Operator::Unary
      include Query
      
      NAME = :"path*"

      ##
      # Path including zero length:
      #
      #    (path :a (path* :p) :b)
      #    => (path :a (path? (path+ :p)) :b)
      #
      # @param  [RDF::Queryable] queryable
      #   the graph or repository to query
      # @param  [Hash{Symbol => Object}] options
      #   any additional keyword options
      # @option options [RDF::Term, RDF::Variable] :subject
      # @option options [RDF::Term, RDF::Variable] :object
      # @yield  [solution]
      #   each matching solution
      # @yieldparam  [RDF::Query::Solution] solution
      # @yieldreturn [void] ignored
      # @see    https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
      def execute(queryable, **options, &block)
        subject, object = options[:subject], options[:object]
        debug(options) {"Path* #{[subject, operands, object].to_sse}"}

        # (:x :p* :y) => (:x (:p+)? :y)
        query = PathOpt.new(PathPlus.new(*operands))
        query.execute(queryable, depth: options[:depth].to_i + 1, **options, &block)
      end
    end # PathStar
  end # Operator
end; end # SPARQL::Algebra

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sparql-3.1.8 lib/sparql/algebra/operator/path_star.rb
sparql-3.1.7 lib/sparql/algebra/operator/path_star.rb
sparql-3.1.6 lib/sparql/algebra/operator/path_star.rb
sparql-3.1.5 lib/sparql/algebra/operator/path_star.rb
sparql-3.1.4 lib/sparql/algebra/operator/path_star.rb
sparql-3.1.3 lib/sparql/algebra/operator/path_star.rb
sparql-3.1.2 lib/sparql/algebra/operator/path_star.rb