Class: RepoMate::Database
- Inherits:
-
Object
- Object
- RepoMate::Database
- Defined in:
- lib/repomate/database.rb
Overview
Class for the database
Instance Method Summary collapse
-
#destroy ⇒ Object
Deletes a categories directory.
-
#exists? ⇒ Boolean
Checks if the database file already exists.
-
#initialize(dbfile) ⇒ Database
constructor
Init.
-
#query(sql) ⇒ Object
Executes a query.
Constructor Details
#initialize(dbfile) ⇒ Database
Init
10 11 12 |
# File 'lib/repomate/database.rb', line 10 def initialize(dbfile) @db = SQLite3::Database.new(dbfile) end |
Instance Method Details
#destroy ⇒ Object
Deletes a categories directory
25 26 27 |
# File 'lib/repomate/database.rb', line 25 def destroy FileUtils.rm_r(@dbfile) if exists? end |
#exists? ⇒ Boolean
Checks if the database file already exists
15 16 17 |
# File 'lib/repomate/database.rb', line 15 def exists? File.exists?(@dbfile) end |
#query(sql) ⇒ Object
Executes a query
20 21 22 |
# File 'lib/repomate/database.rb', line 20 def query(sql) @db.execute(sql) end |