lib/ld/patch/algebra/path.rb
##
# Executes this operator using the given variable `bindings` and a starting term, returning zero or more terms at the end of the path.
#
# @param  [RDF::Queryable] queryable
#   the graph or repository to query
# @param [Hash{Symbol => Object}] options ({})
#   options passed from query
# @option options [Array<RDF::Term>] starting terms
# @return [RDF::Query::Solutions] solutions with `:term` mapping
Executes this operator using the given variable `bindings` and a starting term, returning zero or more terms at the end of the path.
Executes this operator using the given variable ` bindings ` and a starting term returning zero or more terms at the end of the path .
def execute(queryable, options = {})
      solutions = RDF::Query::Solutions.new
      operands.inject(Array(options.fetch(:terms))) do |terms, op|
        case op
        when RDF::URI
          terms.map do |subject|
            queryable.query({subject: subject, predicate: op}).map(&:object)
          end.flatten
        when SPARQL::Algebra::Query
          op.execute(queryable, **options.merge(terms: terms)).map do |soln|
            soln.path
          end.flatten
        else
          raise NotImplementedError, "Unknown path operand #{op.inspect}"
        end
      end.each do |term|
        solutions << RDF::Query::Solution.new(path: term)
      end
      solutions
    end
def execute ( queryable , options = { } ) solutions = RDF :: Query :: Solutions . new operands . inject ( Array ( options . fetch ( :terms ) ) ) do | terms , op | case op when RDF :: URI terms . map do | subject | queryable . query ( { subject : subject , predicate : op } ) . map ( & :object ) end . flatten when SPARQL :: Algebra :: Query op . execute ( queryable , ** options . merge ( terms : terms ) ) . map do | soln | soln . path end . flatten else raise NotImplementedError , "Unknown path operand #{op.inspect}" end end . each do | term | solutions << RDF :: Query :: Solution . new ( path : term ) end solutions end
Executes this operator using the given variable `bindings` and a starting term, returning zero or more terms at the end of the path.
Executes this operator using the given variable ` bindings ` and a starting term returning zero or more terms at the end of the path .
# Iterate updating terms, then create solutions from matched terms # Get path solutions for each term for op
solutions with `:term` mapping
solutions with ` : term ` mapping
RDF::Query::Solutions
queryable
<not_specific>
options
None
<not_specific>
options ({}) options passed from query
options ( {} ) options passed from query