Class: RoadForest::SourceRigor::Parcel
- Inherits:
-
Object
- Object
- RoadForest::SourceRigor::Parcel
show all
- Includes:
- Graph::Normalization
- Defined in:
- lib/roadforest/source-rigor/parcel.rb
Constant Summary
Graph::Normalization::Vocabs
Instance Attribute Summary collapse
Instance Method Summary
collapse
#expand_curie, #expand_curie_pair, #interned_uri, #literal, #normalize_context, #normalize_property, #normalize_resource, #normalize_statement, #normalize_term, #normalize_tuple, #normalize_uri, #relevant_prefixes_for_graph, #root_url, #uri, #vocabularies_in_graph
Instance Attribute Details
#graph ⇒ Object
Returns the value of attribute graph.
8
9
10
|
# File 'lib/roadforest/source-rigor/parcel.rb', line 8
def graph
@graph
end
|
Instance Method Details
#graph_for(resource) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/roadforest/source-rigor/parcel.rb', line 26
def graph_for(resource)
new_graph = RDF::Graph.new
subjects = {}
subjects_for_resource(resource).each do |subject|
subjects[subject] ||= :open
end
until (open_subjects = subjects.keys.find_all{|subject| subjects[subject] == :open }).empty?
open_subjects.each do |subject|
subjects[subject] = :closed
graph.query(:subject => subject) do |statement|
if RDF::Node === statement.object
subjects[statement.object] ||= :open
end
new_graph << statement
end
end
end
new_graph
end
|
#resources ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/roadforest/source-rigor/parcel.rb', line 10
def resources
resource_hash = {}
graph.each_subject do |subject|
next unless RDF::URI === subject
resource_hash[normalize_context(subject)] = true
end
resource_hash.keys
end
|
#subjects_for_resource(resource) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/roadforest/source-rigor/parcel.rb', line 19
def subjects_for_resource(resource)
resource = normalize_context(resource)
graph.each_subject.find_all do |subject|
normalize_context(subject) == resource
end
end
|