Sha256: 9ceee6447fab6fc868ac9a07d8040a2af1ea7bc5f8aa5ac5f6105f23ea5afdc3

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

#This class handels the result when running MRI (or others).
class Baza::Driver::Sqlite3::Result
  #Constructor. This should not be called manually.
  def initialize(driver, result_array)
    @result_array = result_array
    @index = 0
  end

  #Returns a single result.
  def fetch
    result_hash = @result_array[@index]
    return false unless result_hash
    @index += 1

    ret = {}
    result_hash.each do |key, val|
      if (Float(key) rescue false)
        #do nothing.
      elsif !key.is_a?(Symbol)
        ret[key.to_sym] = val
      else
        ret[key] = val
      end
    end

    return ret
  end

  #Loops over every result yielding them.
  def each
    while data = self.fetch
      yield(data)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
baza-0.0.17 include/drivers/sqlite3/sqlite3_result.rb
baza-0.0.16 include/drivers/sqlite3/sqlite3_result.rb
baza-0.0.15 include/drivers/sqlite3/sqlite3_result.rb