Sha256: bb8f533cb2b41c04ea8b6e5584bd6b3fdd1a329674faad68ff4923a7f249ebc6

Contents?: true

Size: 1.39 KB

Versions: 6

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/rdf-sparql-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

6 entries across 6 versions & 1 rubygems

Version Path
sparql-1.99.1 lib/sparql/algebra/operator/path_star.rb
sparql-1.1.9.1 lib/sparql/algebra/operator/path_star.rb
sparql-1.99.0 lib/sparql/algebra/operator/path_star.rb
sparql-1.1.9 lib/sparql/algebra/operator/path_star.rb
sparql-1.1.8 lib/sparql/algebra/operator/path_star.rb
sparql-1.1.7 lib/sparql/algebra/operator/path_star.rb