Class: RDBI::Driver::ODBC::Cursor

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

Instance Method Summary collapse

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_countObject



122
123
124
# File 'lib/rdbi/driver/odbc.rb', line 122

def affected_count
  0
end

#allObject



138
139
140
# File 'lib/rdbi/driver/odbc.rb', line 138

def all
  @rs
end

#coerce_to_arrayObject



171
172
173
# File 'lib/rdbi/driver/odbc.rb', line 171

def coerce_to_array
  @rs
end

#empty?Boolean

Returns:

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

#finishObject



167
168
169
# File 'lib/rdbi/driver/odbc.rb', line 167

def finish
  @handle.drop
end

#firstObject



126
127
128
# File 'lib/rdbi/driver/odbc.rb', line 126

def first
  @rs.first
end

#lastObject



130
131
132
# File 'lib/rdbi/driver/odbc.rb', line 130

def last
  @rs.last
end

#last_row?Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/rdbi/driver/odbc.rb', line 151

def last_row?
  @index == @rs.size
end

#next_rowObject



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

#restObject



134
135
136
# File 'lib/rdbi/driver/odbc.rb', line 134

def rest
  @rs[@index..-1]
end

#result_countObject



118
119
120
# File 'lib/rdbi/driver/odbc.rb', line 118

def result_count
  @rs.size
end

#rewindObject



159
160
161
# File 'lib/rdbi/driver/odbc.rb', line 159

def rewind
  @index = 0
end

#sizeObject



163
164
165
# File 'lib/rdbi/driver/odbc.rb', line 163

def size
  @rs.length
end