Sha256: 670b389455ab5051a9eedcf3bccf4e26ae87640c3d2074bf844106e077ab197f

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL Property Path `path*` (ZeroOrMorePath) operator.
    #
    # @example
    #   (path* :p)
    #
    # @see http://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    http://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, options.merge(depth: options[:depth].to_i + 1), &block)
      end
    end # PathStar
  end # Operator
end; end # SPARQL::Algebra

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sparql-3.0.2 lib/sparql/algebra/operator/path_star.rb
sparql-3.0.1 lib/sparql/algebra/operator/path_star.rb
sparql-3.0.0 lib/sparql/algebra/operator/path_star.rb
sparql-2.2.2 lib/sparql/algebra/operator/path_star.rb
sparql-2.2.1 lib/sparql/algebra/operator/path_star.rb
sparql-2.2.0 lib/sparql/algebra/operator/path_star.rb
sparql-2.1.0 lib/sparql/algebra/operator/path_star.rb
sparql-2.0.0 lib/sparql/algebra/operator/path_star.rb
sparql-2.0.0.beta2 lib/sparql/algebra/operator/path_star.rb
sparql-2.0.0.beta1 lib/sparql/algebra/operator/path_star.rb