Sha256: dcf25a8e62c5231622693b5fe6c6b96d109c996f86dc8c54852e53ffde559709
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 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) 0.upto(column_count - 1) do |i| name = sqlite3_column_name(@handle.value, i).to_sym type = sqlite3_column_type(@handle.value, i) case type when SQLITE_NULL row[name] = nil when SQLITE_TEXT row[name] = sqlite3_column_text(@handle.value, i) when SQLITE_BLOB row[name] = NSData.dataWithBytes(sqlite3_column_blob(@handle.value, i), length: sqlite3_column_bytes(@handle.value, i)) when SQLITE_INTEGER row[name] = sqlite3_column_int64(@handle.value, i) when SQLITE_FLOAT row[name] = sqlite3_column_double(@handle.value, i) end end row end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
motion-sqlite3-1.0.0 | lib/motion-sqlite3/result_set.rb |
motion-sqlite3-0.5.3 | lib/motion-sqlite3/result_set.rb |