Class: SPARQL::Client::Update::DeleteData

Inherits:
Operation show all
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/sparql-client-464d3f76cfd5/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(data, **options) ⇒ DeleteData

Delete statements from the graph

Examples:

DELETE DATA { http://example.org/jhacker http://xmlns.com/foaf/0.1/name \"J. Random Hacker\" .}

data = RDF::Graph.new do |graph|
  graph << [RDF::URI('http://example.org/jhacker'), RDF::Vocab::FOAF.name, "J. Random Hacker"]
end
delete_data(data)

Parameters:



224
225
226
227
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-client-464d3f76cfd5/lib/sparql/client/update.rb', line 224

def initialize(data, **options)
  @data = data
  super(**options)
end

Instance Attribute Details

#dataRDF::Enumerable (readonly)

Returns:



211
212
213
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-client-464d3f76cfd5/lib/sparql/client/update.rb', line 211

def data
  @data
end

Instance Method Details

#graph(uri) ⇒ self

Cause data to be deleted from the graph specified by uri

Parameters:

Returns:

  • (self)


234
235
236
237
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-client-464d3f76cfd5/lib/sparql/client/update.rb', line 234

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

#to_sObject



239
240
241
242
243
244
245
246
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-client-464d3f76cfd5/lib/sparql/client/update.rb', line 239

def to_s
  query_text = 'DELETE DATA {'
  query_text += ' GRAPH ' + SPARQL::Client.serialize_uri(self.options[:graph]) + ' {' if self.options[:graph]
  query_text += "\n"
  query_text += RDF::NTriples::Writer.buffer { |writer| @data.each { |d| writer << d } }
  query_text += '}' if self.options[:graph]
  query_text += "}\n"
end