class SPARQL::Client::Update::InsertData

@see www.w3.org/TR/sparql11-update/#insertData

Attributes

data[R]

@return [RDF::Enumerable]

Public Class Methods

new(data, **options) click to toggle source

Insert statements into the graph

@example INSERT 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
insert_data(data)

@param [Array<RDF::Statement>, RDF::Enumerable] data @param [Hash{Symbol => Object}] options

Calls superclass method SPARQL::Client::Update::Operation::new
# File lib/sparql/client/update.rb, line 174
def initialize(data, **options)
  @data = data
  super(**options)
end

Public Instance Methods

expects_statements?() click to toggle source

InsertData always returns result set

@return [true]

# File lib/sparql/client/update.rb, line 193
def expects_statements?
  false
end
graph(uri) click to toggle source

Cause data to be inserted into the graph specified by `uri`

@param [RDF::URI] uri @return [self]

# File lib/sparql/client/update.rb, line 184
def graph(uri)
  self.options[:graph] = uri
  self
end
to_s() click to toggle source
# File lib/sparql/client/update.rb, line 197
def to_s
  query_text = 'INSERT 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