Class: RDBI::Driver::JDBC::Cursor
- Inherits:
-
Cursor
- Object
- Cursor
- RDBI::Driver::JDBC::Cursor
- Defined in:
- lib/caruby/rdbi/driver/jdbc.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
- #affected_count ⇒ Object
- #all ⇒ Object
- #coerce_to_array ⇒ Object
- #empty? ⇒ Boolean
- #fetch(count = 1) ⇒ Object
- #finish ⇒ Object
- #first ⇒ Object
-
#initialize(handle) ⇒ Cursor
constructor
TODO: update this to use real calls, not array to get this working, we’ll just build the array for now.
- #last ⇒ Object
- #last_row? ⇒ Boolean
- #next_row ⇒ Object
- #rest ⇒ Object
- #result_count ⇒ Object
- #rewind ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(handle) ⇒ Cursor
TODO: update this to use real calls, not array to get this working, we’ll just build the array for now.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 139 def initialize(handle) super handle @index = 0 @rs = [] return if handle.nil? rs = handle.getResultSet = rs.getMetaData while rs.next data = [] (1...getColumnCount).each do |n| data << parse_column(rs, n, ) end @rs << data end end |
Instance Method Details
#[](index) ⇒ Object
195 196 197 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 195 def [](index) @rs[index] end |
#affected_count ⇒ Object
170 171 172 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 170 def affected_count 0 end |
#all ⇒ Object
186 187 188 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 186 def all @rs end |
#coerce_to_array ⇒ Object
219 220 221 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 219 def coerce_to_array @rs end |
#empty? ⇒ Boolean
203 204 205 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 203 def empty? @rs.empty? end |
#fetch(count = 1) ⇒ Object
190 191 192 193 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 190 def fetch(count = 1) return [] if last_row? @rs[@index, count] end |
#finish ⇒ Object
215 216 217 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 215 def finish @handle.close end |
#first ⇒ Object
174 175 176 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 174 def first @rs.first end |
#last ⇒ Object
178 179 180 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 178 def last @rs.last end |
#last_row? ⇒ Boolean
199 200 201 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 199 def last_row? @index == @rs.size end |
#next_row ⇒ Object
159 160 161 162 163 164 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 159 def next_row return nil if last_row? val = @rs[@index] @index += 1 val end |
#rest ⇒ Object
182 183 184 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 182 def rest @rs[@index..-1] end |
#result_count ⇒ Object
166 167 168 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 166 def result_count @rs.size end |
#rewind ⇒ Object
207 208 209 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 207 def rewind @index = 0 end |
#size ⇒ Object
211 212 213 |
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 211 def size @rs.length end |