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

#initialize(*graph) ⇒ AggregateGraph

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

#graphsArray<Graph> (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

#addObject



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

def add; raise ReadOnlyGraphException; end

#bind(namespace) ⇒ Object

Parameters:

Raises:



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

def bind(namespace); raise ReadOnlyGraphException; end

#bnodesArray<BNode>

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

#commitObject



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

def commit; raise ReadOnlyGraphException; end

#contains?(triple) ⇒ Boolean

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

#destroy(configuration = nil) ⇒ Object



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

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

#eql?(other) ⇒ Boolean

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

#n3Object



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

def n3; raise ReadOnlyGraphException; end

#nsbindingHash{String => Namespace}

Returns:



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

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

#objectsArray<Resource>

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

#parse(stream, uri, options = {}) ⇒ Object

Parameters:

Raises:



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

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

#predicatesArray<Resource>

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

#removeObject



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

def remove; raise ReadOnlyGraphException; end

#rollbackObject



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

def rollback; raise ReadOnlyGraphException; end

#sizeInteger

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

#subjectsArray<Resource>

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

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

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

#uri_bindingHash{URIRef => Namespace}

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