Class: DataStore

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/bb_analytics/models/data_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDataStore

Returns a new instance of DataStore.



9
10
11
# File 'lib/bb_analytics/models/data_store.rb', line 9

def initialize
  self.setup_db
end

Instance Attribute Details

#dbObject

Returns the value of attribute db.



7
8
9
# File 'lib/bb_analytics/models/data_store.rb', line 7

def db
  @db
end

Instance Method Details

#clear_dataObject



49
50
51
52
# File 'lib/bb_analytics/models/data_store.rb', line 49

def clear_data
  File.delete(db_location) rescue nil
  #self.setup_db
end

#db_locationObject



58
59
60
# File 'lib/bb_analytics/models/data_store.rb', line 58

def db_location
  "#{ENV['HOME']}/.bb_analytics/bba.db"
end

#setup_dbObject



54
55
56
# File 'lib/bb_analytics/models/data_store.rb', line 54

def setup_db
  self.db = SQLite3::Database.new self.db_location rescue nil
end