Class: RdfContext::AggregateGraph
- 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
-
#graphs ⇒ Array<Graph>
readonly
List of constituent graphs.
Attributes inherited from Graph
#allow_n3, #identifier, #store
Instance Method Summary collapse
- #add ⇒ Object
- #bind(namespace) ⇒ Object
-
#bnodes ⇒ Array<BNode>
Get all BNodes with usage count used within graph.
-
#close(configuration = {})
Close the graphs.
- #commit ⇒ Object
-
#contains?(triple) ⇒ Boolean
Check to see if this graph contains the specified triple.
- #destroy(configuration = nil) ⇒ Object
-
#eql?(other) ⇒ Boolean
Only compares to another AggregateGraph.
-
#initialize(*graph) ⇒ AggregateGraph
constructor
List of graphs to aggregate.
- #n3 ⇒ Object
- #nsbinding ⇒ Hash{String => Namespace}
-
#objects ⇒ Array<Resource>
List of distinct objects in graph.
-
#open(configuration = {})
Open the graphs.
- #parse(stream, uri, options = {}) ⇒ Object
-
#predicates ⇒ Array<Resource>
List of distinct predicates in graph.
- #remove ⇒ Object
- #rollback ⇒ Object
-
#size ⇒ Integer
Number of Triples in the graph.
-
#subjects ⇒ Array<Resource>
List of distinct subjects in graph.
-
#triples(triple = Triple.new(nil, nil, nil)) {|triple, context| ... } ⇒ Array<Triple>
Triples from graph, optionally matching subject, predicate, or object.
- #uri_binding ⇒ Hash{URIRef => Namespace}
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
12 13 14 |
# File 'lib/rdf_context/aggregate_graph.rb', line 12 def initialize(*graph) @graphs = graph end |
Instance Attribute Details
Instance Method Details
#add ⇒ Object
23 |
# File 'lib/rdf_context/aggregate_graph.rb', line 23 def add; raise ReadOnlyGraphException; end |
#bind(namespace) ⇒ Object
28 |
# File 'lib/rdf_context/aggregate_graph.rb', line 28 def bind(namespace); raise ReadOnlyGraphException; end |
#bnodes ⇒ Array<BNode>
Get all BNodes with usage count used within graph
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 |
#commit ⇒ Object
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
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
99 100 101 |
# File 'lib/rdf_context/aggregate_graph.rb', line 99 def eql?(other) other.is_a?(AggregateGraph) ? super : false end |
#n3 ⇒ Object
34 |
# File 'lib/rdf_context/aggregate_graph.rb', line 34 def n3; raise ReadOnlyGraphException; end |
#nsbinding ⇒ Hash{String => Namespace}
104 105 106 |
# File 'lib/rdf_context/aggregate_graph.rb', line 104 def nsbinding @graphs.inject({}) {|memo, g| memo.merge(g.nsbinding)} end |
#objects ⇒ Array<Resource>
List of distinct objects in graph
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
32 |
# File 'lib/rdf_context/aggregate_graph.rb', line 32 def parse(stream, uri, = {}); raise ReadOnlyGraphException; end |
#predicates ⇒ Array<Resource>
List of distinct predicates in graph
62 63 64 |
# File 'lib/rdf_context/aggregate_graph.rb', line 62 def predicates @graphs.inject([]) {|memo, g| memo += g.predicates} end |
#remove ⇒ Object
25 |
# File 'lib/rdf_context/aggregate_graph.rb', line 25 def remove; raise ReadOnlyGraphException; end |
#rollback ⇒ Object
21 |
# File 'lib/rdf_context/aggregate_graph.rb', line 21 def rollback; raise ReadOnlyGraphException; end |
#size ⇒ Integer
Number of Triples in the graph
50 51 52 |
# File 'lib/rdf_context/aggregate_graph.rb', line 50 def size @graphs.inject(0) {|memo, g| memo += g.size} end |
#subjects ⇒ Array<Resource>
List of distinct subjects in graph
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.
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 |