The ResultSet object encapsulates the enumerability of a query’s output. It is a simple cursor over the data that the query returns. It will very rarely (if ever) be instantiated directly. Instead, client’s should obtain a ResultSet instance via Statement#execute.

Included Modules
[R] columns An array of the column names for this result set (may be empty)
[R] types An array of the column types for this result set (may be empty)
Classes and Modules
Module SQLite::ResultSet::FieldsContainer
Module SQLite::ResultSet::TypesContainer
Public Class methods
new( db, sql )

Create a new ResultSet attached to the given database, using the given sql text.

    # File lib/sqlite/resultset.rb, line 62
62:     def initialize( db, sql )
63:       @db = db
64:       @sql = sql
65:       commence
66:     end
Public Instance methods

Close the result set. Attempting to perform any operation (including close) on a closed result set will have undefined results.

    # File lib/sqlite/resultset.rb, line 90
90:     def close
91:       API.finalize( @vm )
92:     end
each() {|row| ...}

Required by the Enumerable mixin. Provides an internal iterator over the rows of the result set.

     # File lib/sqlite/resultset.rb, line 160
160:     def each
161:       while
162:         yield row
163:       end
164:     end

Query whether the cursor has reached the end of the result set or not.

     # File lib/sqlite/resultset.rb, line 104
104:     def eof?
105:       @eof
106:     end

Obtain the next row from the cursor. If there are no more rows to be had, this will return nil. If type translation is active on the corresponding database, the values in the row will be translated according to their types.

The returned value will be an array, unless Database#results_as_hash has been set to true, in which case the returned value will be a hash.

For arrays, the column names are accessible via the fields property, and the column types are accessible via the types property.

For hashes, the column names are the keys of the hash, and the column types are accessible via the types property.

     # File lib/sqlite/resultset.rb, line 121
121:     def next
122:       return nil if @eof
124:       if @current_row
125:         result, @current_row = @current_row, nil
126:       else
127:         result = API.step( @vm )
128:         check_eof( result )
129:       end
131:       unless @eof
132:         row = result[:row]
134:         if @db.type_translation
135:           row = row ).map do |type, value|
136:             @db.translator.translate( type, value )
137:           end
138:         end
140:         if @db.results_as_hash
141:           new_row = Hash[ *( row ).flatten ) ]
142:           row.each_with_index { |value,idx| new_row[idx] = value }
143:           row = new_row
144:         else
145:           row.extend FieldsContainer unless row.respond_to?(:fields)
146:           row.fields = @columns
147:         end
149:         row.extend TypesContainer
150:         row.types = @types
152:         return row
153:       end
155:       nil
156:     end

Reset the cursor, so that a result set which has reached end-of-file can be rewound and reiterated. Note: this uses an experimental API, which is subject to change. Use at your own risk.

     # File lib/sqlite/resultset.rb, line 97
 97:     def reset
 98:       API.finalize( @vm )
 99:       commence
100:       @eof = false
101:     end