Class: RDBI::Driver::ODBC::Cursor
- Inherits:
-
Cursor
- Object
- Cursor
- RDBI::Driver::ODBC::Cursor
- Defined in:
- lib/rdbi/driver/odbc.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
only #fetch works reliably with ODBC, so we just build the array upfront.
- #last ⇒ Object
- #last_row? ⇒ Boolean
- #next_row ⇒ Object
- #rest ⇒ Object
- #result_count ⇒ Object
- #rewind ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(handle) ⇒ Cursor
only #fetch works reliably with ODBC, so we just build the array upfront.
102 103 104 105 106 107 108 109 |
# File 'lib/rdbi/driver/odbc.rb', line 102 def initialize(handle) super handle @index = 0 @rs = [] while r = @handle.fetch @rs << r end end |
Instance Method Details
#[](index) ⇒ Object
147 148 149 |
# File 'lib/rdbi/driver/odbc.rb', line 147 def [](index) @rs[index] end |
#affected_count ⇒ Object
122 123 124 |
# File 'lib/rdbi/driver/odbc.rb', line 122 def affected_count 0 end |
#all ⇒ Object
138 139 140 |
# File 'lib/rdbi/driver/odbc.rb', line 138 def all @rs end |
#coerce_to_array ⇒ Object
171 172 173 |
# File 'lib/rdbi/driver/odbc.rb', line 171 def coerce_to_array @rs end |
#empty? ⇒ Boolean
155 156 157 |
# File 'lib/rdbi/driver/odbc.rb', line 155 def empty? @rs.empty? end |
#fetch(count = 1) ⇒ Object
142 143 144 145 |
# File 'lib/rdbi/driver/odbc.rb', line 142 def fetch(count = 1) return [] if last_row? @rs[@index, count] end |
#finish ⇒ Object
167 168 169 |
# File 'lib/rdbi/driver/odbc.rb', line 167 def finish @handle.drop end |
#first ⇒ Object
126 127 128 |
# File 'lib/rdbi/driver/odbc.rb', line 126 def first @rs.first end |
#last ⇒ Object
130 131 132 |
# File 'lib/rdbi/driver/odbc.rb', line 130 def last @rs.last end |
#last_row? ⇒ Boolean
151 152 153 |
# File 'lib/rdbi/driver/odbc.rb', line 151 def last_row? @index == @rs.size end |
#next_row ⇒ Object
111 112 113 114 115 116 |
# File 'lib/rdbi/driver/odbc.rb', line 111 def next_row return nil if last_row? val = @rs[@index] @index += 1 val end |
#rest ⇒ Object
134 135 136 |
# File 'lib/rdbi/driver/odbc.rb', line 134 def rest @rs[@index..-1] end |
#result_count ⇒ Object
118 119 120 |
# File 'lib/rdbi/driver/odbc.rb', line 118 def result_count @rs.size end |
#rewind ⇒ Object
159 160 161 |
# File 'lib/rdbi/driver/odbc.rb', line 159 def rewind @index = 0 end |
#size ⇒ Object
163 164 165 |
# File 'lib/rdbi/driver/odbc.rb', line 163 def size @rs.length end |