rdf-rdfa 0.3.5.1 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,34 +0,0 @@
1
- module RDF
2
- class Graph
3
- # Resource properties
4
- #
5
- # Properties arranged as a hash with the predicate Term as index to an array of resources or literals
6
- #
7
- # Example:
8
- # graph.load(':foo a :bar; rdfs:label "An example" .', "http://example.com/")
9
- # graph.resources(URI.new("http://example.com/subject")) =>
10
- # {
11
- # "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" => [<http://example.com/#bar>],
12
- # "http://example.com/#label" => ["An example"]
13
- # }
14
- def properties(subject, recalc = false)
15
- @properties ||= {}
16
- @properties.delete(subject.to_s) if recalc
17
- @properties[subject.to_s] ||= begin
18
- hash = Hash.new
19
- self.query(:subject => subject) do |statement|
20
- pred = statement.predicate.to_s
21
-
22
- hash[pred] ||= []
23
- hash[pred] << statement.object
24
- end
25
- hash
26
- end
27
- end
28
-
29
- # Get type(s) of subject, returns a list of symbols
30
- def type_of(subject)
31
- query(:subject => subject, :predicate => RDF.type).map {|st| st.object}
32
- end
33
- end
34
- end