Sha256: 3f03023e84f2e1573dbd04e89671222e24035d55346758450e187f1e2b2e8ffc

Contents?: true

Size: 1.33 KB

Versions: 19

Compression:

Stored size: 1.33 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL GraphPattern `ask` operator.
    #
    # @example
    #   (prefix ((: <http://example/>))
    #     (ask
    #       (bgp (triple :x :p ?x))))
    #
    # @see http://www.w3.org/TR/rdf-sparql-query/#ask
    class Ask < Operator::Unary
      include Query
      
      NAME = [:ask]

      ##
      # Executes this query on the given `queryable` graph or repository.
      # Returns true if any solutions are found, false otherwise.
      #
      # @param  [RDF::Queryable] queryable
      #   the graph or repository to query
      # @param  [Hash{Symbol => Object}] options
      #   any additional keyword options
      # @return [RDF::Literal::Boolean]
      #   the resulting solution sequence
      # @see    http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
      def execute(queryable, options = {})
        debug(options) {"Ask #{operands.first}"}
        boolean(!operands.last.
          execute(queryable, options.merge(:depth => options[:depth].to_i + 1)).
          empty?)
      end
      
      ##
      # Returns an optimized version of this query.
      #
      # Return optimized query
      #
      # @return [Union, RDF::Query] `self`
      def optimize
        operands = operands.map(&:optimize)
      end
    end # Ask
  end # Operator
end; end # SPARQL::Algebra

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
sparql-1.1.1 lib/sparql/algebra/operator/ask.rb
sparql-1.1.0 lib/sparql/algebra/operator/ask.rb
sparql-1.1.0p0 lib/sparql/algebra/operator/ask.rb
sparql-1.0.8 lib/sparql/algebra/operator/ask.rb
sparql-1.0.7 lib/sparql/algebra/operator/ask.rb
sparql-1.0.6 lib/sparql/algebra/operator/ask.rb
sparql-1.0.5 lib/sparql/algebra/operator/ask.rb
sparql-1.0.4 lib/sparql/algebra/operator/ask.rb
sparql-1.0.3 lib/sparql/algebra/operator/ask.rb
sparql-1.0.2 lib/sparql/algebra/operator/ask.rb
sparql-1.0.1 lib/sparql/algebra/operator/ask.rb
sparql-1.0.0 lib/sparql/algebra/operator/ask.rb
sparql-0.3.3 lib/sparql/algebra/operator/ask.rb
sparql-0.3.2 lib/sparql/algebra/operator/ask.rb
sparql-0.3.1 lib/sparql/algebra/operator/ask.rb
sparql-0.3.0 lib/sparql/algebra/operator/ask.rb
sparql-0.1.1 lib/sparql/algebra/operator/ask.rb
sparql-0.1.0 lib/sparql/algebra/operator/ask.rb
sparql-0.0.2 lib/sparql/algebra/operator/ask.rb