Class: ActiveTriples::ExtendedBoundedDescription
- Inherits:
-
Object
- Object
- ActiveTriples::ExtendedBoundedDescription
- Includes:
- RDF::Enumerable, RDF::Queryable
- Defined in:
- lib/active_triples/util/extended_bounded_description.rb
Overview
this implementation requires that the ‘source_graph` remain unchanged while iterating over the description. The safest way to achive this is to use an immutable `RDF::Dataset` (e.g. a `Repository#snapshot`).
Bounds the scope of an ‘RDF::Queryable` to a subgraph defined from a source graph, a starting node, and a list of “ancestors” terms, by the following process:
Include in the subgraph:
1. All statements in the source graph where the subject of the statement
is the starting node.
2. Add the starting node to the ancestors list.
2. Recursively, for all statements already in the subgraph, include in
the subgraph the Extended Bounded Description for each object node,
unless the object is in the ancestors list.
The list of “ancestors” is empty by default.
This subgraph this process yields can be considered as a description of the starting node.
Compare to Concise Bounded Description (www.w3.org/Submission/CBD/), the common subgraph scope used for SPARQL DESCRIBE queries.
Instance Attribute Summary collapse
- #ancestors ⇒ Object readonly
-
#source_graph ⇒ Object
readonly
RDF::Queryable.
-
#starting_node ⇒ Object
readonly
Returns the value of attribute starting_node.
Instance Method Summary collapse
- #each_statement ⇒ Object (also: #each)
-
#initialize(source_graph, starting_node, ancestors = []) ⇒ ExtendedBoundedDescription
constructor
By analogy to Concise Bounded Description.
Constructor Details
#initialize(source_graph, starting_node, ancestors = []) ⇒ ExtendedBoundedDescription
By analogy to Concise Bounded Description.
46 47 48 49 50 |
# File 'lib/active_triples/util/extended_bounded_description.rb', line 46 def initialize(source_graph, starting_node, ancestors = []) @source_graph = source_graph @starting_node = starting_node @ancestors = ancestors end |
Instance Attribute Details
#ancestors ⇒ Object (readonly)
38 39 40 |
# File 'lib/active_triples/util/extended_bounded_description.rb', line 38 def ancestors @ancestors end |
#source_graph ⇒ Object (readonly)
Returns RDF::Queryable.
38 |
# File 'lib/active_triples/util/extended_bounded_description.rb', line 38 attr_reader :ancestors, :source_graph, :starting_node |
#starting_node ⇒ Object (readonly)
Returns the value of attribute starting_node.
38 |
# File 'lib/active_triples/util/extended_bounded_description.rb', line 38 attr_reader :ancestors, :source_graph, :starting_node |
Instance Method Details
#each_statement ⇒ Object Also known as: each
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/active_triples/util/extended_bounded_description.rb', line 54 def each_statement ancestors = @ancestors.dup if block_given? statements = source_graph.query(subject: starting_node).each statements.each_statement { |st| yield st } ancestors << starting_node statements.each_object do |object| next if object.literal? || ancestors.include?(object) ExtendedBoundedDescription .new(source_graph, object, ancestors).each do |statement| yield statement end end end enum_statement end |