Class: RDBI::Driver::PostgreSQL::Cursor
- Inherits:
-
Cursor
- Object
- Cursor
- RDBI::Driver::PostgreSQL::Cursor
- Defined in:
- lib/rdbi/driver/postgresql.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
- #affected_count ⇒ Object
- #all ⇒ Object
- #empty? ⇒ Boolean
- #fetch(count = 1) ⇒ Object
- #finish ⇒ Object
- #first ⇒ Object
-
#initialize(handle, schema) ⇒ Cursor
constructor
A new instance of Cursor.
- #last ⇒ Object
- #last_row? ⇒ Boolean
- #next_row ⇒ Object
- #rest ⇒ Object
- #result_count ⇒ Object
- #rewind ⇒ Object
Constructor Details
#initialize(handle, schema) ⇒ Cursor
Returns a new instance of Cursor.
163 164 165 166 167 168 |
# File 'lib/rdbi/driver/postgresql.rb', line 163 def initialize(handle, schema) super(handle) @index = 0 @stub_datetime = DateTime.now.strftime( " %z" ) @schema = schema end |
Instance Method Details
#[](index) ⇒ Object
208 209 210 |
# File 'lib/rdbi/driver/postgresql.rb', line 208 def [](index) fix_dates(@handle[index].values) end |
#affected_count ⇒ Object
187 188 189 |
# File 'lib/rdbi/driver/postgresql.rb', line 187 def affected_count @handle.cmd_tuples end |
#all ⇒ Object
204 205 206 |
# File 'lib/rdbi/driver/postgresql.rb', line 204 def all fix_dates(fetch_range(0, result_count-1)) end |
#empty? ⇒ Boolean
220 221 222 |
# File 'lib/rdbi/driver/postgresql.rb', line 220 def empty? result_count == 0 end |
#fetch(count = 1) ⇒ Object
170 171 172 173 174 175 |
# File 'lib/rdbi/driver/postgresql.rb', line 170 def fetch(count=1) return [] if last_row? a = [] count.times { a.push(next_row) } return a end |
#finish ⇒ Object
224 225 226 |
# File 'lib/rdbi/driver/postgresql.rb', line 224 def finish @handle.clear end |
#first ⇒ Object
191 192 193 |
# File 'lib/rdbi/driver/postgresql.rb', line 191 def first fix_dates(@handle[0].values) end |
#last ⇒ Object
195 196 197 |
# File 'lib/rdbi/driver/postgresql.rb', line 195 def last fix_dates(@handle[-1].values) end |
#last_row? ⇒ Boolean
212 213 214 |
# File 'lib/rdbi/driver/postgresql.rb', line 212 def last_row? @index == result_count end |
#next_row ⇒ Object
177 178 179 180 181 |
# File 'lib/rdbi/driver/postgresql.rb', line 177 def next_row val = @handle[@index].values @index += 1 fix_dates(val) end |
#rest ⇒ Object
199 200 201 202 |
# File 'lib/rdbi/driver/postgresql.rb', line 199 def rest oindex, @index = @index, result_count-1 fix_dates(fetch_range(oindex, @index)) end |
#result_count ⇒ Object
183 184 185 |
# File 'lib/rdbi/driver/postgresql.rb', line 183 def result_count @handle.num_tuples end |
#rewind ⇒ Object
216 217 218 |
# File 'lib/rdbi/driver/postgresql.rb', line 216 def rewind @index = 0 end |