Class: Recog::DBManager

Inherits:
Object
  • Object
show all
Defined in:
lib/recog/db_manager.rb

Constant Summary collapse

DefaultDatabasePath =
File.expand_path( File.join( File.dirname(__FILE__), "..", "..", "xml") )

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = DefaultDatabasePath) ⇒ DBManager

Returns a new instance of DBManager.


10
11
12
13
# File 'lib/recog/db_manager.rb', line 10

def initialize(path = DefaultDatabasePath)
  self.path = path
  reload
end

Instance Attribute Details

#databasesObject

Returns the value of attribute databases


6
7
8
# File 'lib/recog/db_manager.rb', line 6

def databases
  @databases
end

#pathObject

Returns the value of attribute path


6
7
8
# File 'lib/recog/db_manager.rb', line 6

def path
  @path
end

Instance Method Details

#load_databasesObject


15
16
17
18
19
20
21
22
23
# File 'lib/recog/db_manager.rb', line 15

def load_databases
  if File.directory?(self.path)
    Dir[self.path + "/*.xml"].each do |dbxml|
      self.databases << DB.new(dbxml)
    end
  else
    self.databases << DB.new(self.path)
  end
end

#reloadObject


25
26
27
28
# File 'lib/recog/db_manager.rb', line 25

def reload
  self.databases = []
  load_databases
end