rdf 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -1
- data/VERSION +1 -1
- data/lib/rdf.rb +25 -22
- data/lib/rdf/enumerable.rb +554 -0
- data/lib/rdf/format.rb +239 -41
- data/lib/rdf/model/graph.rb +82 -0
- data/lib/rdf/{literal.rb → model/literal.rb} +47 -4
- data/lib/rdf/{node.rb → model/node.rb} +0 -0
- data/lib/rdf/{resource.rb → model/resource.rb} +0 -0
- data/lib/rdf/{statement.rb → model/statement.rb} +12 -0
- data/lib/rdf/{uri.rb → model/uri.rb} +20 -7
- data/lib/rdf/model/value.rb +135 -0
- data/lib/rdf/ntriples.rb +35 -2
- data/lib/rdf/ntriples/format.rb +4 -4
- data/lib/rdf/ntriples/reader.rb +2 -2
- data/lib/rdf/ntriples/writer.rb +26 -19
- data/lib/rdf/query.rb +4 -4
- data/lib/rdf/query/pattern.rb +3 -3
- data/lib/rdf/query/solution.rb +2 -2
- data/lib/rdf/query/variable.rb +3 -3
- data/lib/rdf/reader.rb +85 -16
- data/lib/rdf/repository.rb +104 -12
- data/lib/rdf/version.rb +1 -1
- data/lib/rdf/vocab.rb +171 -0
- data/lib/rdf/vocab/cc.rb +18 -0
- data/lib/rdf/vocab/dc.rb +63 -0
- data/lib/rdf/vocab/doap.rb +45 -0
- data/lib/rdf/vocab/exif.rb +168 -0
- data/lib/rdf/vocab/foaf.rb +69 -0
- data/lib/rdf/vocab/http.rb +26 -0
- data/lib/rdf/vocab/owl.rb +59 -0
- data/lib/rdf/{vocabulary → vocab}/rdf.rb +7 -1
- data/lib/rdf/vocab/rdfs.rb +17 -0
- data/lib/rdf/{vocabulary → vocab}/rss.rb +6 -1
- data/lib/rdf/vocab/sioc.rb +93 -0
- data/lib/rdf/vocab/skos.rb +36 -0
- data/lib/rdf/vocab/wot.rb +21 -0
- data/lib/rdf/vocab/xhtml.rb +9 -0
- data/lib/rdf/vocab/xsd.rb +58 -0
- data/lib/rdf/writer.rb +123 -16
- metadata +26 -27
- data/lib/rdf/graph.rb +0 -197
- data/lib/rdf/reader/ntriples.rb +0 -5
- data/lib/rdf/value.rb +0 -76
- data/lib/rdf/vocabulary.rb +0 -133
- data/lib/rdf/vocabulary/cc.rb +0 -9
- data/lib/rdf/vocabulary/dc.rb +0 -9
- data/lib/rdf/vocabulary/doap.rb +0 -9
- data/lib/rdf/vocabulary/exif.rb +0 -9
- data/lib/rdf/vocabulary/foaf.rb +0 -9
- data/lib/rdf/vocabulary/http.rb +0 -9
- data/lib/rdf/vocabulary/owl.rb +0 -9
- data/lib/rdf/vocabulary/rdfs.rb +0 -9
- data/lib/rdf/vocabulary/sioc.rb +0 -9
- data/lib/rdf/vocabulary/skos.rb +0 -9
- data/lib/rdf/vocabulary/wot.rb +0 -9
- data/lib/rdf/vocabulary/xhtml.rb +0 -9
- data/lib/rdf/vocabulary/xsd.rb +0 -9
- data/lib/rdf/writer/ntriples.rb +0 -5
@@ -0,0 +1,36 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# Simple Knowledge Organization System (SKOS) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://www.w3.org/TR/skos-reference/skos.html
|
6
|
+
class SKOS < Vocabulary("http://www.w3.org/2004/02/skos/core#")
|
7
|
+
property :altLabel
|
8
|
+
property :broadMatch
|
9
|
+
property :broader
|
10
|
+
property :broaderTransitive
|
11
|
+
property :changeNote
|
12
|
+
property :closeMatch
|
13
|
+
property :definition
|
14
|
+
property :editorialNote
|
15
|
+
property :exactMatch
|
16
|
+
property :example
|
17
|
+
property :hasTopConcept
|
18
|
+
property :hiddenLabel
|
19
|
+
property :historyNote
|
20
|
+
property :inScheme
|
21
|
+
property :mappingRelation
|
22
|
+
property :member
|
23
|
+
property :memberList
|
24
|
+
property :narrowMatch
|
25
|
+
property :narrower
|
26
|
+
property :narrowerTransitive
|
27
|
+
property :notation
|
28
|
+
property :note
|
29
|
+
property :prefLabel
|
30
|
+
property :related
|
31
|
+
property :relatedMatch
|
32
|
+
property :scopeNote
|
33
|
+
property :semanticRelation
|
34
|
+
property :topConceptOf
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# Web of Trust (WOT) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://xmlns.com/wot/0.1/
|
6
|
+
class WOT < Vocabulary("http://xmlns.com/wot/0.1/")
|
7
|
+
property :assurance
|
8
|
+
property :encryptedTo
|
9
|
+
property :encrypter
|
10
|
+
property :fingerprint
|
11
|
+
property :hasKey
|
12
|
+
property :hex_id
|
13
|
+
property :identity
|
14
|
+
property :length
|
15
|
+
property :pubkeyAddress
|
16
|
+
property :sigdate
|
17
|
+
property :signed
|
18
|
+
property :signer
|
19
|
+
property :sigtime
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# XML Schema (XSD) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://www.w3.org/XML/Schema
|
6
|
+
# @see http://www.w3.org/TR/xmlschema-2/#built-in-datatypes
|
7
|
+
class XSD < Vocabulary("http://www.w3.org/2001/XMLSchema#")
|
8
|
+
# XML Schema built-in primitive types
|
9
|
+
# @see http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes
|
10
|
+
property :NOTATION
|
11
|
+
property :QName
|
12
|
+
property :anyURI
|
13
|
+
property :base64Binary
|
14
|
+
property :boolean
|
15
|
+
property :date
|
16
|
+
property :dateTime
|
17
|
+
property :decimal
|
18
|
+
property :double
|
19
|
+
property :duration
|
20
|
+
property :float
|
21
|
+
property :gDay
|
22
|
+
property :gMonth
|
23
|
+
property :gMonthDay
|
24
|
+
property :gYear
|
25
|
+
property :gYearMonth
|
26
|
+
property :hexBinary
|
27
|
+
property :string
|
28
|
+
property :time
|
29
|
+
|
30
|
+
# XML Schema built-in derived types
|
31
|
+
# @see http://www.w3.org/TR/xmlschema-2/#built-in-derived
|
32
|
+
property :ENTITIES
|
33
|
+
property :ENTITY
|
34
|
+
property :ID
|
35
|
+
property :IDREF
|
36
|
+
property :IDREFS
|
37
|
+
property :NCName
|
38
|
+
property :NMTOKEN
|
39
|
+
property :NMTOKENS
|
40
|
+
property :Name
|
41
|
+
property :byte
|
42
|
+
property :int
|
43
|
+
property :integer
|
44
|
+
property :language
|
45
|
+
property :long
|
46
|
+
property :negativeInteger
|
47
|
+
property :nonNegativeInteger
|
48
|
+
property :nonPositiveInteger
|
49
|
+
property :normalizedString
|
50
|
+
property :positiveInteger
|
51
|
+
property :short
|
52
|
+
property :token
|
53
|
+
property :unsignedByte
|
54
|
+
property :unsignedInt
|
55
|
+
property :unsignedLong
|
56
|
+
property :unsignedShort
|
57
|
+
end
|
58
|
+
end
|
data/lib/rdf/writer.rb
CHANGED
@@ -2,30 +2,100 @@ module RDF
|
|
2
2
|
##
|
3
3
|
# An RDF serializer.
|
4
4
|
#
|
5
|
+
# @example Iterating over known RDF writer classes
|
6
|
+
# RDF::Writer.each { |klass| puts klass.name }
|
7
|
+
#
|
8
|
+
# @example Obtaining an RDF writer class
|
9
|
+
# RDF::Writer.for(:ntriples) #=> RDF::NTriples::Writer
|
10
|
+
# RDF::Writer.for("spec/data/output.nt")
|
11
|
+
# RDF::Writer.for(:file_name => "spec/data/output.nt")
|
12
|
+
# RDF::Writer.for(:file_extension => "nt")
|
13
|
+
# RDF::Writer.for(:content_type => "text/plain")
|
14
|
+
#
|
15
|
+
# @example Instantiating an RDF writer class
|
16
|
+
# RDF::Writer.for(:ntriples).new($stdout) { |writer| ... }
|
17
|
+
#
|
18
|
+
# @example Serializing RDF statements to a file
|
19
|
+
# RDF::Writer.open("spec/data/output.nt") do |writer|
|
20
|
+
# graph.each_statement do |statement|
|
21
|
+
# writer << statement
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# @example Serializing RDF statements to a string
|
26
|
+
# RDF::Writer.for(:ntriples).buffer do |writer|
|
27
|
+
# graph.each_statement do |statement|
|
28
|
+
# writer << statement
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
#
|
5
32
|
# @abstract
|
33
|
+
# @see RDF::Format
|
34
|
+
# @see RDF::Reader
|
6
35
|
class Writer
|
7
|
-
|
8
|
-
|
9
|
-
include Enumerable
|
36
|
+
extend ::Enumerable
|
37
|
+
include ::Enumerable
|
10
38
|
|
11
39
|
##
|
12
40
|
# Enumerates known RDF writer classes.
|
13
41
|
#
|
14
42
|
# @yield [klass]
|
15
43
|
# @yieldparam [Class]
|
44
|
+
# @return [Enumerator]
|
16
45
|
def self.each(&block)
|
17
|
-
|
46
|
+
@@subclasses.each(&block)
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# Finds an RDF writer class based on the given criteria.
|
51
|
+
#
|
52
|
+
# @overload for(format)
|
53
|
+
# Finds an RDF writer class based on a symbolic name.
|
54
|
+
#
|
55
|
+
# @param [Symbol] format
|
56
|
+
# @return [Class]
|
57
|
+
#
|
58
|
+
# @overload for(filename)
|
59
|
+
# Finds an RDF writer class based on a file name.
|
60
|
+
#
|
61
|
+
# @param [String] filename
|
62
|
+
# @return [Class]
|
63
|
+
#
|
64
|
+
# @overload for(options = {})
|
65
|
+
# Finds an RDF writer class based on various options.
|
66
|
+
#
|
67
|
+
# @param [Hash{Symbol => Object}] options
|
68
|
+
# @option options [String, #to_s] :file_name (nil)
|
69
|
+
# @option options [Symbol, #to_sym] :file_extension (nil)
|
70
|
+
# @option options [String, #to_s] :content_type (nil)
|
71
|
+
# @return [Class]
|
72
|
+
#
|
73
|
+
# @return [Class]
|
74
|
+
def self.for(options = {})
|
75
|
+
if format = Format.for(options)
|
76
|
+
format.writer
|
77
|
+
end
|
18
78
|
end
|
19
79
|
|
20
80
|
##
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
81
|
+
# Retrieves the RDF serialization format class for this writer class.
|
82
|
+
#
|
83
|
+
# @return [Class]
|
84
|
+
def self.format(klass = nil)
|
85
|
+
if klass.nil?
|
86
|
+
Format.each do |format|
|
87
|
+
if format.reader == self
|
88
|
+
return format
|
89
|
+
end
|
90
|
+
end
|
91
|
+
nil # not found
|
26
92
|
end
|
27
93
|
end
|
28
94
|
|
95
|
+
class << self
|
96
|
+
alias_method :format_class, :format
|
97
|
+
end
|
98
|
+
|
29
99
|
def self.buffer(*args, &block)
|
30
100
|
require 'stringio' unless defined?(StringIO)
|
31
101
|
|
@@ -36,10 +106,8 @@ module RDF
|
|
36
106
|
end
|
37
107
|
|
38
108
|
def self.open(filename, options = {}, &block)
|
39
|
-
options[:format] ||= :ntriples # FIXME
|
40
|
-
|
41
109
|
File.open(filename, 'wb') do |file|
|
42
|
-
self.for(options[:format]).new(file, options, &block)
|
110
|
+
self.for(options[:format] || filename).new(file, options, &block)
|
43
111
|
end
|
44
112
|
end
|
45
113
|
|
@@ -131,6 +199,49 @@ module RDF
|
|
131
199
|
raise NotImplementedError # override in subclasses
|
132
200
|
end
|
133
201
|
|
202
|
+
##
|
203
|
+
# @param [Value] value
|
204
|
+
# @return [String]
|
205
|
+
def format_value(value, options = {})
|
206
|
+
case value
|
207
|
+
when String then format_literal(value, options)
|
208
|
+
when RDF::Literal then format_literal(value, options)
|
209
|
+
when RDF::URI then format_uri(value, options)
|
210
|
+
when RDF::Node then format_node(value, options)
|
211
|
+
else nil
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
##
|
216
|
+
# @param [URI] value
|
217
|
+
# @param [Hash{Symbol => Object}] options
|
218
|
+
# @return [String]
|
219
|
+
# @raise [NotImplementedError] unless implemented in subclass
|
220
|
+
# @abstract
|
221
|
+
def format_uri(value, options = {})
|
222
|
+
raise NotImplementedError # override in subclasses
|
223
|
+
end
|
224
|
+
|
225
|
+
##
|
226
|
+
# @param [Node] value
|
227
|
+
# @param [Hash{Symbol => Object}] options
|
228
|
+
# @return [String]
|
229
|
+
# @raise [NotImplementedError] unless implemented in subclass
|
230
|
+
# @abstract
|
231
|
+
def format_node(value, options = {})
|
232
|
+
raise NotImplementedError # override in subclasses
|
233
|
+
end
|
234
|
+
|
235
|
+
##
|
236
|
+
# @param [Literal, String, #to_s] value
|
237
|
+
# @param [Hash{Symbol => Object}] options
|
238
|
+
# @return [String]
|
239
|
+
# @raise [NotImplementedError] unless implemented in subclass
|
240
|
+
# @abstract
|
241
|
+
def format_literal(value, options = {})
|
242
|
+
raise NotImplementedError # override in subclasses
|
243
|
+
end
|
244
|
+
|
134
245
|
protected
|
135
246
|
|
136
247
|
def puts(*args)
|
@@ -188,10 +299,6 @@ module RDF
|
|
188
299
|
super
|
189
300
|
end
|
190
301
|
|
191
|
-
def self.format(klass)
|
192
|
-
# TODO
|
193
|
-
end
|
194
|
-
|
195
302
|
end
|
196
303
|
|
197
304
|
class WriterError < IOError; end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arto Bendiken
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-09 00:00:00 +01:00
|
13
13
|
default_executable: rdf
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -68,10 +68,15 @@ files:
|
|
68
68
|
- bin/rdf-subjects
|
69
69
|
- lib/df.rb
|
70
70
|
- lib/rdf/cli.rb
|
71
|
+
- lib/rdf/enumerable.rb
|
71
72
|
- lib/rdf/format.rb
|
72
|
-
- lib/rdf/graph.rb
|
73
|
-
- lib/rdf/literal.rb
|
74
|
-
- lib/rdf/node.rb
|
73
|
+
- lib/rdf/model/graph.rb
|
74
|
+
- lib/rdf/model/literal.rb
|
75
|
+
- lib/rdf/model/node.rb
|
76
|
+
- lib/rdf/model/resource.rb
|
77
|
+
- lib/rdf/model/statement.rb
|
78
|
+
- lib/rdf/model/uri.rb
|
79
|
+
- lib/rdf/model/value.rb
|
75
80
|
- lib/rdf/ntriples/format.rb
|
76
81
|
- lib/rdf/ntriples/reader.rb
|
77
82
|
- lib/rdf/ntriples/writer.rb
|
@@ -80,31 +85,25 @@ files:
|
|
80
85
|
- lib/rdf/query/solution.rb
|
81
86
|
- lib/rdf/query/variable.rb
|
82
87
|
- lib/rdf/query.rb
|
83
|
-
- lib/rdf/reader/ntriples.rb
|
84
88
|
- lib/rdf/reader.rb
|
85
89
|
- lib/rdf/repository.rb
|
86
|
-
- lib/rdf/resource.rb
|
87
|
-
- lib/rdf/statement.rb
|
88
|
-
- lib/rdf/uri.rb
|
89
|
-
- lib/rdf/value.rb
|
90
90
|
- lib/rdf/version.rb
|
91
|
-
- lib/rdf/
|
92
|
-
- lib/rdf/
|
93
|
-
- lib/rdf/
|
94
|
-
- lib/rdf/
|
95
|
-
- lib/rdf/
|
96
|
-
- lib/rdf/
|
97
|
-
- lib/rdf/
|
98
|
-
- lib/rdf/
|
99
|
-
- lib/rdf/
|
100
|
-
- lib/rdf/
|
101
|
-
- lib/rdf/
|
102
|
-
- lib/rdf/
|
103
|
-
- lib/rdf/
|
104
|
-
- lib/rdf/
|
105
|
-
- lib/rdf/
|
106
|
-
- lib/rdf/
|
107
|
-
- lib/rdf/writer/ntriples.rb
|
91
|
+
- lib/rdf/vocab/cc.rb
|
92
|
+
- lib/rdf/vocab/dc.rb
|
93
|
+
- lib/rdf/vocab/doap.rb
|
94
|
+
- lib/rdf/vocab/exif.rb
|
95
|
+
- lib/rdf/vocab/foaf.rb
|
96
|
+
- lib/rdf/vocab/http.rb
|
97
|
+
- lib/rdf/vocab/owl.rb
|
98
|
+
- lib/rdf/vocab/rdf.rb
|
99
|
+
- lib/rdf/vocab/rdfs.rb
|
100
|
+
- lib/rdf/vocab/rss.rb
|
101
|
+
- lib/rdf/vocab/sioc.rb
|
102
|
+
- lib/rdf/vocab/skos.rb
|
103
|
+
- lib/rdf/vocab/wot.rb
|
104
|
+
- lib/rdf/vocab/xhtml.rb
|
105
|
+
- lib/rdf/vocab/xsd.rb
|
106
|
+
- lib/rdf/vocab.rb
|
108
107
|
- lib/rdf/writer.rb
|
109
108
|
- lib/rdf.rb
|
110
109
|
has_rdoc: false
|
data/lib/rdf/graph.rb
DELETED
@@ -1,197 +0,0 @@
|
|
1
|
-
module RDF
|
2
|
-
##
|
3
|
-
# An RDF graph.
|
4
|
-
class Graph < Resource
|
5
|
-
include Enumerable
|
6
|
-
|
7
|
-
# @return [URI]
|
8
|
-
attr_accessor :uri
|
9
|
-
|
10
|
-
# @return [Array<Statement>]
|
11
|
-
attr_accessor :data
|
12
|
-
|
13
|
-
##
|
14
|
-
# @param [URI] uri
|
15
|
-
# @yield [graph]
|
16
|
-
# @yieldparam [Graph]
|
17
|
-
def initialize(uri = nil, options = {}, &block)
|
18
|
-
@uri, @options = uri, options
|
19
|
-
|
20
|
-
if block_given?
|
21
|
-
case block.arity
|
22
|
-
when 1 then block.call(self)
|
23
|
-
else instance_eval(&block)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
##
|
29
|
-
# Returns `true`.
|
30
|
-
#
|
31
|
-
# @return [Boolean]
|
32
|
-
def graph?
|
33
|
-
true
|
34
|
-
end
|
35
|
-
|
36
|
-
##
|
37
|
-
# @return [Boolean]
|
38
|
-
def named?() !unnamed? end
|
39
|
-
|
40
|
-
##
|
41
|
-
# @return [Boolean]
|
42
|
-
def unnamed?() uri.nil? end
|
43
|
-
|
44
|
-
##
|
45
|
-
# @return [Integer]
|
46
|
-
def size() @data.size end
|
47
|
-
|
48
|
-
##
|
49
|
-
# @yield [statement]
|
50
|
-
# @yieldparam [Array<Statement>]
|
51
|
-
# @return [Graph]
|
52
|
-
def each(&block)
|
53
|
-
each_statement(&block)
|
54
|
-
end
|
55
|
-
|
56
|
-
##
|
57
|
-
# @yield [statement]
|
58
|
-
# @yieldparam [Array<Statement>]
|
59
|
-
# @return [Graph]
|
60
|
-
def each_statement(&block)
|
61
|
-
@data.each(&block)
|
62
|
-
self
|
63
|
-
end
|
64
|
-
|
65
|
-
##
|
66
|
-
# @yield [triple]
|
67
|
-
# @yieldparam [Array(Value)]
|
68
|
-
# @return [Graph]
|
69
|
-
def each_triple(&block)
|
70
|
-
@data.each do |statement|
|
71
|
-
block.call(*statement.to_triple)
|
72
|
-
end
|
73
|
-
self
|
74
|
-
end
|
75
|
-
|
76
|
-
##
|
77
|
-
# @yield [quad]
|
78
|
-
# @yieldparam [Array(Value)]
|
79
|
-
# @return [Graph]
|
80
|
-
def each_quad(&block)
|
81
|
-
@data.each do |statement|
|
82
|
-
block.call(*statement.to_quad) # FIXME?
|
83
|
-
end
|
84
|
-
self
|
85
|
-
end
|
86
|
-
|
87
|
-
##
|
88
|
-
# @yield [context]
|
89
|
-
# @yieldparam [Resource]
|
90
|
-
# @return [Graph]
|
91
|
-
def each_context(&block)
|
92
|
-
block.call(uri) unless unnamed?
|
93
|
-
self
|
94
|
-
end
|
95
|
-
|
96
|
-
##
|
97
|
-
# @yield [subject]
|
98
|
-
# @yieldparam [Resource]
|
99
|
-
# @return [Graph]
|
100
|
-
def each_subject(&block)
|
101
|
-
@data.each do |statement|
|
102
|
-
block.call(statement.subject)
|
103
|
-
end
|
104
|
-
self
|
105
|
-
end
|
106
|
-
|
107
|
-
##
|
108
|
-
# @yield [predicate]
|
109
|
-
# @yieldparam [URI]
|
110
|
-
# @return [Graph]
|
111
|
-
def each_predicate(&block)
|
112
|
-
@data.each do |statement|
|
113
|
-
block.call(statement.predicate)
|
114
|
-
end
|
115
|
-
self
|
116
|
-
end
|
117
|
-
|
118
|
-
##
|
119
|
-
# @yield [object]
|
120
|
-
# @yieldparam [Value]
|
121
|
-
# @return [Graph]
|
122
|
-
def each_object(&block)
|
123
|
-
@data.each do |statement|
|
124
|
-
block.call(statement.object)
|
125
|
-
end
|
126
|
-
self
|
127
|
-
end
|
128
|
-
|
129
|
-
##
|
130
|
-
# @return [Array<Statement>]
|
131
|
-
def statements(&block)
|
132
|
-
block_given? ? each_statement(&block) : @data
|
133
|
-
end
|
134
|
-
|
135
|
-
##
|
136
|
-
# @return [Array<Array(Value)>]
|
137
|
-
def triples(&block)
|
138
|
-
block_given? ? each_triple(&block) : map { |statement| statement.to_triple }
|
139
|
-
end
|
140
|
-
|
141
|
-
##
|
142
|
-
# @return [Array<Array(Value)>]
|
143
|
-
def quads(&block)
|
144
|
-
block_given? ? each_quad(&block) : map { |statement| statement.to_quad }
|
145
|
-
end
|
146
|
-
|
147
|
-
##
|
148
|
-
# @return [Resource]
|
149
|
-
def context() uri end
|
150
|
-
|
151
|
-
##
|
152
|
-
# @return [Array<Resource>]
|
153
|
-
def contexts
|
154
|
-
block_given? ? each_context(&block) : (named? ? [uri] : [])
|
155
|
-
end
|
156
|
-
|
157
|
-
##
|
158
|
-
# @return [Array<Resource>]
|
159
|
-
def subjects
|
160
|
-
block_given? ? each_subject(&block) : map(&:subject)
|
161
|
-
end
|
162
|
-
|
163
|
-
##
|
164
|
-
# @return [Array<URI>]
|
165
|
-
def predicates
|
166
|
-
block_given? ? each_predicate(&block) : map(&:predicate)
|
167
|
-
end
|
168
|
-
|
169
|
-
##
|
170
|
-
# @return [Array<Value>]
|
171
|
-
def objects
|
172
|
-
block_given? ? each_object(&block) : map(&:object)
|
173
|
-
end
|
174
|
-
|
175
|
-
##
|
176
|
-
# @param [Statement, Array(Value)]
|
177
|
-
# @return [Graph]
|
178
|
-
def <<(statement)
|
179
|
-
@data << case statement
|
180
|
-
when Array then Statement.new(*statement)
|
181
|
-
when Statement then statement
|
182
|
-
else statement
|
183
|
-
end
|
184
|
-
self
|
185
|
-
end
|
186
|
-
|
187
|
-
##
|
188
|
-
# @return [URI]
|
189
|
-
def to_uri() uri end
|
190
|
-
|
191
|
-
##
|
192
|
-
# @return [String]
|
193
|
-
def to_s
|
194
|
-
named? ? uri.to_s : "<>"
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|