Class: SPARQL::Client::Update::DeleteInsert

Inherits:
Operation show all
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/sparql-client-c651818e506f/lib/sparql/client/update.rb

Overview

Instance Attribute Summary collapse

Attributes inherited from Operation

#options

Instance Method Summary collapse

Methods inherited from Operation

#expects_statements?, #silent

Constructor Details

#initialize(_delete_graph, _insert_graph = nil, _where_graph = nil, options = {}) ⇒ DeleteInsert

Returns a new instance of DeleteInsert



256
257
258
259
260
261
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-client-c651818e506f/lib/sparql/client/update.rb', line 256

def initialize(_delete_graph, _insert_graph = nil, _where_graph = nil, options = {})
  @delete_graph = _delete_graph
  @insert_graph = _insert_graph
  @where_graph = _where_graph
  super(options)
end

Instance Attribute Details

#delete_graphObject (readonly)

Returns the value of attribute delete_graph



253
254
255
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-client-c651818e506f/lib/sparql/client/update.rb', line 253

def delete_graph
  @delete_graph
end

#insert_graphObject (readonly)

Returns the value of attribute insert_graph



252
253
254
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-client-c651818e506f/lib/sparql/client/update.rb', line 252

def insert_graph
  @insert_graph
end

#where_graphObject (readonly)

Returns the value of attribute where_graph



254
255
256
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-client-c651818e506f/lib/sparql/client/update.rb', line 254

def where_graph
  @where_graph
end

Instance Method Details

#graph(uri) ⇒ self

Cause data to be deleted and inserted from the graph specified by uri

Parameters:

Returns:

  • (self)


268
269
270
271
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-client-c651818e506f/lib/sparql/client/update.rb', line 268

def graph(uri)
  self.options[:graph] = uri
  self
end

#to_sObject



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-client-c651818e506f/lib/sparql/client/update.rb', line 273

def to_s
  buffer = []

  if self.options[:graph]
    buffer << "WITH"
    buffer << SPARQL::Client.serialize_uri(self.options[:graph])
  end
  if delete_graph and !delete_graph.empty?
    serialized_delete = SPARQL::Client.serialize_patterns delete_graph, true
    buffer << "DELETE {\n"
    buffer += serialized_delete
    buffer << "}\n"
  end
  if insert_graph and !insert_graph.empty?
    buffer << "INSERT {\n"
    buffer += SPARQL::Client.serialize_patterns insert_graph, true
    buffer << "}\n"
  end
    buffer << "WHERE {\n"
  if where_graph
    buffer += SPARQL::Client.serialize_patterns where_graph, true
  elsif serialized_delete
    buffer += serialized_delete
  end
  buffer << "}\n"
  buffer.join(' ')
end