Class: RepoMate::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/repomate/database.rb

Overview

Class for the database

Instance Method Summary collapse

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

#destroyObject

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

Returns:

  • (Boolean)


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