Sha256: b6339f55ce83f1f5d7abda372b88347abb75c441e7e4abe4169de7af27dc444e
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
module SQLite3 class ResultSet def initialize(statement, handle) @statement = statement @handle = handle end def each(&block) until @statement.done? yield current_row @statement.step end end private def current_row row = {} column_count = sqlite3_column_count(@handle.value_with_autorelease) 0.upto(column_count - 1) do |i| name = sqlite3_column_name(@handle.value_with_autorelease, i).to_sym type = sqlite3_column_type(@handle.value_with_autorelease, i) case type when SQLITE_NULL row[name] = nil when SQLITE_TEXT row[name] = sqlite3_column_text(@handle.value_with_autorelease, i) when SQLITE_BLOB row[name] = NSData.dataWithBytes(sqlite3_column_blob(@handle.value_with_autorelease, i), length: sqlite3_column_bytes(@handle.value_with_autorelease, i)) when SQLITE_INTEGER row[name] = sqlite3_column_int64(@handle.value_with_autorelease, i) when SQLITE_FLOAT row[name] = sqlite3_column_double(@handle.value_with_autorelease, i) end end row end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
motion-sqlite3-2.0.0 | lib/motion-sqlite3/result_set.rb |