Class: Recog::DBManager
- Inherits:
-
Object
- Object
- Recog::DBManager
- Defined in:
- lib/recog/db_manager.rb
Constant Summary collapse
- DefaultDatabasePath =
File.( File.join( File.dirname(__FILE__), "..", "..", "xml") )
Instance Attribute Summary collapse
-
#databases ⇒ Object
Returns the value of attribute databases.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path = DefaultDatabasePath) ⇒ DBManager
constructor
A new instance of DBManager.
- #load_databases ⇒ Object
- #reload ⇒ Object
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
#databases ⇒ Object
Returns the value of attribute databases.
6 7 8 |
# File 'lib/recog/db_manager.rb', line 6 def databases @databases end |
#path ⇒ Object
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_databases ⇒ Object
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 |
#reload ⇒ Object
25 26 27 28 |
# File 'lib/recog/db_manager.rb', line 25 def reload self.databases = [] load_databases end |