Class: RdfContext::QuotedGraph

Inherits:
Graph show all
Defined in:
lib/rdf_context/quoted_graph.rb

Overview

QuotedGraph - Supports N3 Formulae.

QuotedGraphs behave like other graphs, except that the triples are not considered for inference rules and their statements are not held has truth. Triples from a QuotedGraph are not returned from a ConjunctiveGraph in the same store space.

Within N3, a QuotedGraph is represented as a set of statements contained between _and __

{ [ x:firstname  "Ora" ] dc:wrote [ dc:title  "Moby Dick" ] } a n3:falsehood .

Instance Attribute Summary

Attributes inherited from Graph

#allow_n3, #identifier, #store, #triples

Instance Method Summary collapse

Methods inherited from Graph

#<<, #==, #[], #add_seq, #add_triple, #bind, #bnodes, #close, #commit, #contains?, #context_aware?, #destroy, #get_by_type, #graph?, #has_bnode_identifier?, #hash, #initialize, #inspect, #isomorphic?, #merge!, #namespace, #nsbinding, #objects, #open, #parse, #predicates, #prefix, #properties, #qname, #remove, #rollback, #seq, #serialize, #size, #subjects, #sync_properties, #to_ntriples, #to_rdfxml, #to_s, #type_of, #uri_binding

Methods inherited from Resource

#bnode?, #graph?, #literal?, parse, #resource?, #uri?

Constructor Details

This class inherits a constructor from RdfContext::Graph

Instance Method Details

#add(*triples) ⇒ Graph

Adds one or more extant triples to a graph. Delegates to Store.

Examples:

g = Graph.new;
t1 = Triple.new(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new);
t2 = Triple.new(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new);
g.add(t1, t2, ...)

Parameters:

  • triples (Array<Triple>)

    one or more triples. Last element may be a hash for options

  • [Resource] (Hash)

    a customizable set of options

Returns:

  • (Graph)

    Returns the graph



24
25
26
27
28
29
# File 'lib/rdf_context/quoted_graph.rb', line 24

def add(*triples)
  options = triples.last.is_a?(Hash) ? triples.pop : {}
  ctx = options[:context] || @default_context || self
  triples.each {|t| @store.add(t, ctx, true)}
  self
end

#n3String

Return an n3 identifier for the Graph

Returns:



33
34
35
# File 'lib/rdf_context/quoted_graph.rb', line 33

def n3
  "{#{self.identifier.to_n3}}"
end