diff --git a/src/app.rb b/src/app.rb index 4afeac0..c7dc02a 100755 --- a/src/app.rb +++ b/src/app.rb @@ -6,6 +6,8 @@ require "slim" require "sqlite3" require "sassc" +require_relative "database.rb" + def get_random_subtitle subtitles = File.readlines "misc/subtitles.txt" subtitles.sample.chomp diff --git a/src/database.rb b/src/database.rb new file mode 100644 index 0000000..99f7870 --- /dev/null +++ b/src/database.rb @@ -0,0 +1,15 @@ +DEFAULT_DB_PATH = "db/database.db" + +class Database + attr_reader :name, :db_path + def initialize(name, db_path=DEFAULT_DB_PATH) + @name = name + @db_path = db_path + end + + def get_handle + db = SQLite3::Database.new @db_path + db.results_as_hash = true + return db + end +end