Class: RDF::Oxigraph::SPARQL::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf/oxigraph/sparql.rb

Overview

A small SPARQL::Client-shaped wrapper around a repository (anything that responds to #sparql and #sparql_update). Covers the string-based query/update surface; the chainable query-builder DSL of the sparql-client gem is out of scope.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository) ⇒ Client

Returns a new instance of Client.



47
48
49
# File 'lib/rdf/oxigraph/sparql.rb', line 47

def initialize(repository)
  @repository = repository
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



45
46
47
# File 'lib/rdf/oxigraph/sparql.rb', line 45

def repository
  @repository
end

Instance Method Details

#query(query_string, **options) ⇒ Object

Execute a SPARQL query string. update: true routes to #update (mirrors the sparql-client gem's convention used by some callers).



53
54
55
56
# File 'lib/rdf/oxigraph/sparql.rb', line 53

def query(query_string, **options)
  return update(query_string) if options[:update]
  @repository.sparql(query_string)
end

#update(update_string) ⇒ Object

Execute a SPARQL Update string.



59
60
61
62
# File 'lib/rdf/oxigraph/sparql.rb', line 59

def update(update_string, **)
  @repository.sparql_update(update_string)
  self
end