Class: RdfContext::AggregateGraph

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

Overview

AggregateGraph - A read-only graph composed of multiple other graphs.

Essentially a ConjunctiveGraph over an explicit subset of the entire store.

Instance Attribute Summary (collapse)

Attributes inherited from Graph

#allow_n3, #identifier, #store

Instance Method Summary (collapse)

Methods inherited from Graph

#<<, #==, #[], #add_seq, #add_triple, #context_aware?, #get_by_type, #graph?, #has_bnode_identifier?, #hash, #inspect, #isomorphic?, #merge!, #namespace, #prefix, #properties, #qname, #seq, #serialize, #sync_properties, #to_ntriples, #to_rdfxml, #to_s, #type_of

Methods inherited from Resource

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

Constructor Details

- (AggregateGraph) initialize(*graph)

List of graphs to aggregate

Parameters:

  • graph (Array<Graph>)

    List of constituent graphs



12
13
14
# File 'lib/rdf_context/aggregate_graph.rb', line 12

def initialize(*graph)
  @graphs = graph
end

Instance Attribute Details

- (Array<Graph>) graphs (readonly)

List of constituent graphs

Returns:



8
9
10
# File 'lib/rdf_context/aggregate_graph.rb', line 8

def graphs
  @graphs
end

Instance Method Details

- (Object) add



23
# File 'lib/rdf_context/aggregate_graph.rb', line 23

def add; raise ReadOnlyGraphException; end

- (Object) bind(namespace)

Parameters:

Raises:



28
# File 'lib/rdf_context/aggregate_graph.rb', line 28

def bind(namespace); raise ReadOnlyGraphException; end

- (Array<BNode>) bnodes

Get all BNodes with usage count used within graph

Returns:



92
93
94
# File 'lib/rdf_context/aggregate_graph.rb', line 92

def bnodes
  @graphs.inject([]) {|memo, g| memo += g.bnodes}
end

- close(configuration = {})

This method returns an undefined value.

Close the graphs



44
45
46
# File 'lib/rdf_context/aggregate_graph.rb', line 44

def close(configuration = {})
  @graphs.each {|g| g.close(configuration)}
end

- (Object) commit



19
# File 'lib/rdf_context/aggregate_graph.rb', line 19

def commit; raise ReadOnlyGraphException; end

- (Boolean) contains?(triple)

Check to see if this graph contains the specified triple

Parameters:

  • triple (Triple)

    Triple to match, may be a pattern triple or nil

Returns:

  • (Boolean)


86
87
88
# File 'lib/rdf_context/aggregate_graph.rb', line 86

def contains?(triple)
  @graphs.any? {|g| g.contains?(triple) }
end

- (Object) destroy(configuration = nil)



17
# File 'lib/rdf_context/aggregate_graph.rb', line 17

def destroy(configuration = nil); raise ReadOnlyGraphException; end

- (Boolean) eql?(other)

Only compares to another AggregateGraph. Compares each sub-graph

Parameters:

Returns:

  • (Boolean)


99
100
101
# File 'lib/rdf_context/aggregate_graph.rb', line 99

def eql?(other)
  other.is_a?(AggregateGraph) ? super : false
end

- (Object) n3



34
# File 'lib/rdf_context/aggregate_graph.rb', line 34

def n3; raise ReadOnlyGraphException; end

- (Hash{String => Namespace}) nsbinding

Returns:



104
105
106
# File 'lib/rdf_context/aggregate_graph.rb', line 104

def nsbinding
  @graphs.inject({}) {|memo, g| memo.merge(g.nsbinding)}
end

- (Array<Resource>) objects

List of distinct objects in graph

Returns:



68
69
70
# File 'lib/rdf_context/aggregate_graph.rb', line 68

def objects
  @graphs.inject([]) {|memo, g| memo += g.objects}
end

- open(configuration = {})

This method returns an undefined value.

Open the graphs



38
39
40
# File 'lib/rdf_context/aggregate_graph.rb', line 38

def open(configuration = {})
  @graphs.each {|g| g.open(configuration)}
end

- (Object) parse(stream, uri, options = {})

Parameters:

Raises:



32
# File 'lib/rdf_context/aggregate_graph.rb', line 32

def parse(stream, uri, options = {}); raise ReadOnlyGraphException; end

- (Array<Resource>) predicates

List of distinct predicates in graph

Returns:



62
63
64
# File 'lib/rdf_context/aggregate_graph.rb', line 62

def predicates
  @graphs.inject([]) {|memo, g| memo += g.predicates}
end

- (Object) remove



25
# File 'lib/rdf_context/aggregate_graph.rb', line 25

def remove; raise ReadOnlyGraphException; end

- (Object) rollback



21
# File 'lib/rdf_context/aggregate_graph.rb', line 21

def rollback; raise ReadOnlyGraphException; end

- (Integer) size

Number of Triples in the graph

Returns:

  • (Integer)


50
51
52
# File 'lib/rdf_context/aggregate_graph.rb', line 50

def size
  @graphs.inject(0) {|memo, g| memo += g.size}
end

- (Array<Resource>) subjects

List of distinct subjects in graph

Returns:



56
57
58
# File 'lib/rdf_context/aggregate_graph.rb', line 56

def subjects
  @graphs.inject([]) {|memo, g| memo += g.subjects}
end

- (Array<Triple>) triples(triple = Triple.new(nil, nil, nil)) {|triple, context| ... }

Triples from graph, optionally matching subject, predicate, or object. Delegates to Store#triples.

Parameters:

  • triple (Triple) (defaults to: Triple.new(nil, nil, nil))

    (Triple.new) Triple to match, may be a pattern triple or nil

Yields:

  • (triple, context)

Yield Parameters:

Returns:



80
81
82
# File 'lib/rdf_context/aggregate_graph.rb', line 80

def triples(triple = Triple.new(nil, nil, nil), &block) # :yields: triple, context
  @graphs.inject([]) {|memo, g| memo += g.triples(triple, &block)}
end

- (Hash{URIRef => Namespace}) uri_binding

Returns:



109
110
111
# File 'lib/rdf_context/aggregate_graph.rb', line 109

def uri_binding
  @graphs.inject({}) {|memo, g| memo.merge(g.uri_binding)}
end