Sha256: 50bc5dfbc55fa5b731aedee4ae22eda9beee2375801cad06caea05429f8366f8

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 KB

Contents

require File.join(File.dirname(__FILE__), "graph")

module RdfContext
  # 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 .
  class QuotedGraph < Graph
    ## 
    # Adds one or more extant triples to a graph. Delegates to Store.
    #
    # ==== Example
    #   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, ...)
    #
    # @param [Triple] triples:: one or more triples. Last element may be a hash for options
    # <em>options[:context]</em>:: Graph context in which to deposit triples, defaults to default_context or self
    # @return [Graph]:: Returns the graph
    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
    
    # Return an n3 identifier for the Graph
    def n3
      "{#{self.identifier.to_n3}}"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rdf_context-0.5.6 lib/rdf_context/quoted_graph.rb
rdf_context-0.5.5 lib/rdf_context/quoted_graph.rb
rdf_context-0.5.3 lib/rdf_context/quoted_graph.rb
rdf_context-0.5.2 lib/rdf_context/quoted_graph.rb
rdf_context-0.5.1 lib/rdf_context/quoted_graph.rb
rdf_context-0.5.0 lib/rdf_context/quoted_graph.rb