class SPARQL::Algebra::Operator::Ask
The SPARQL
GraphPattern `ask` operator.
Applications can use the ASK form to test whether or not a query pattern has a solution. No information is returned about the possible query solutions, just whether or not a solution exists.
@example
(prefix ((: <http://example/>)) (ask (bgp (triple :x :p ?x))))
Constants
- NAME
Public Instance Methods
execute(queryable, **options) { |res| ... }
click to toggle source
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
@yield [RDF::Literal::Boolean] @yieldparam [RDF::Query::Solution] solution @yieldreturn [void] ignored @return [RDF::Literal::Boolean]\ @see www.w3.org/TR/sparql11-query/#sparqlAlgebra
# File lib/sparql/algebra/operator/ask.rb, line 32 def execute(queryable, **options) debug(options) {"Ask #{operands.first}"} res = boolean(!queryable.query(operands.last, depth: options[:depth].to_i + 1, **options).empty?) yield res if block_given? res end
query_yields_boolean?()
click to toggle source
Query
results in a boolean result (e.g., ASK) @return [Boolean]
# File lib/sparql/algebra/operator/ask.rb, line 41 def query_yields_boolean? true end