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

Inherits:
Operation
  • Object
show all
Defined in:
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 { <example.org/jhacker> <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:

  • data (Array<RDF::Statement>, RDF::Enumerable)
  • options (Hash{Symbol => Object})


224
225
226
227
# File 'lib/sparql/client/update.rb', line 224

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

Instance Attribute Details

#dataRDF::Enumerable (readonly)

Returns:

  • (RDF::Enumerable)


211
212
213
# File '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:

  • uri (RDF::URI)

Returns:

  • (self)


234
235
236
237
# File '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 '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