redlander 0.2.2 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,37 +0,0 @@
1
- module Redlander
2
-
3
- # Wrapper for a librdf_stream object.
4
- module StatementIterator
5
-
6
- include Enumerable
7
-
8
- # Iterate over statements in the stream.
9
- def each
10
- # TODO: The options specify matching criteria: subj, pred, obj;
11
- # if an option is not specified, it matches any value,
12
- # so with no options given, all statements will be returned.
13
- if block_given?
14
- while Redland.librdf_stream_end(@rdf_stream).zero?
15
- yield current
16
- Redland.librdf_stream_next(@rdf_stream).zero?
17
- end
18
- else
19
- raise ::LocalJumpError.new("no block given")
20
- end
21
- end
22
-
23
-
24
- private
25
-
26
- # Get the current Statement in the stream.
27
- def current
28
- rdf_statement = Redland.librdf_stream_get_object(@rdf_stream)
29
- statement = Statement.new(rdf_statement)
30
- # not using Statement#model= in order to avoid re-adding the statement to the model
31
- statement.instance_variable_set(:@model, @model)
32
- statement
33
- end
34
-
35
- end
36
-
37
- end