Class: Baza::Driver::Sqlite3Java::UnbufferedResult
- Inherits:
-
ResultBase
- Object
- ResultBase
- Baza::Driver::Sqlite3Java::UnbufferedResult
show all
- Defined in:
- lib/baza/driver/sqlite3_java/unbuffered_result.rb
Instance Method Summary
collapse
Methods inherited from ResultBase
#to_a, #to_a_enum, #to_enum
Constructor Details
#initialize(_driver, result_set) ⇒ UnbufferedResult
Returns a new instance of UnbufferedResult.
2
3
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/baza/driver/sqlite3_java/unbuffered_result.rb', line 2
def initialize(_driver, result_set)
@result_set = result_set
return unless @result_set
metadata = @result_set.meta_data
@columns_count = metadata.column_count
@columns = []
1.upto(@columns_count) do |count|
@columns << metadata.column_name(count).to_sym
end
end
|
Instance Method Details
#each ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/baza/driver/sqlite3_java/unbuffered_result.rb', line 27
def each
loop do
data = fetch
if data
yield data
else
break
end
end
end
|
#fetch ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/baza/driver/sqlite3_java/unbuffered_result.rb', line 15
def fetch
result = @result_set.next if @result_set
return nil unless result
hash = {}
@columns_count.times do |count|
hash[@columns[count]] = @result_set.string(count + 1)
end
hash
end
|