class Ua::SQLite3Table

Public Class Methods

new(db, table) click to toggle source
# File lib/ua/uadb.rb, line 3
def initialize(db, table)
       require 'SQLite3'
       @db, @table = db, table
       @database = ::SQLite3::Database.new(@db + ".db") 
    end

Public Instance Methods

[](a) click to toggle source
# File lib/ua/uadb.rb, line 9
    def [](a)
       case a
         when lambda{|x| Integer(x) rescue false}
                 @database.execute "select * from #{@table} where id=?", a.to_i
               when Hash
                 k = a.keys
                 x = k.map{|name| "#{name} = ?"}.join(" and ")
                 y = k.map{|name| a[name]}
                 @database.execute "select * from #{@table} where " + x, y 
         end
end