class SQLite3::Database

Public Instance Methods

[](idx) click to toggle source
# File lib/storage/sqlite3hash.rb, line 17
def [](idx)
  result = execute("select data from tmud where id = ?;", idx.to_i)
  result.first.first ? result.first.first : nil
end
[]=(idx, data) click to toggle source
# File lib/storage/sqlite3hash.rb, line 21
def []=(idx, data)
  result = execute("insert into tmud values (?, ?);", idx.to_i, data)
rescue Exception
  result = execute("update tmud set data = ? where id = ?;", data, idx.to_i)
ensure
  data
end
delete(idx) click to toggle source
# File lib/storage/sqlite3hash.rb, line 32
def delete(idx)
  result = execute("delete from tmud where id = ?;", idx.to_i)
rescue Exception
end
has_key?(idx) click to toggle source
# File lib/storage/sqlite3hash.rb, line 28
def has_key?(idx)
  result = execute("select data from tmud where id = ?;", idx.to_i)
  result.first.first ? true : false
end