Class: RDBI::Driver::PostgreSQL::Cursor

Inherits:
Cursor
  • Object
show all
Defined in:
lib/rdbi/driver/postgresql.rb

Instance Method Summary collapse

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_countObject



187
188
189
# File 'lib/rdbi/driver/postgresql.rb', line 187

def affected_count
  @handle.cmd_tuples
end

#allObject



204
205
206
# File 'lib/rdbi/driver/postgresql.rb', line 204

def all
  fix_dates(fetch_range(0, result_count-1))
end

#empty?Boolean

Returns:

  • (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

#finishObject



224
225
226
# File 'lib/rdbi/driver/postgresql.rb', line 224

def finish
  @handle.clear
end

#firstObject



191
192
193
# File 'lib/rdbi/driver/postgresql.rb', line 191

def first
  fix_dates(@handle[0].values)
end

#lastObject



195
196
197
# File 'lib/rdbi/driver/postgresql.rb', line 195

def last
  fix_dates(@handle[-1].values)
end

#last_row?Boolean

Returns:

  • (Boolean)


212
213
214
# File 'lib/rdbi/driver/postgresql.rb', line 212

def last_row?
  @index == result_count
end

#next_rowObject



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

#restObject



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_countObject



183
184
185
# File 'lib/rdbi/driver/postgresql.rb', line 183

def result_count
  @handle.num_tuples
end

#rewindObject



216
217
218
# File 'lib/rdbi/driver/postgresql.rb', line 216

def rewind
  @index = 0
end