Class: Recog::DBManager
- Inherits:
-
Object
- Object
- Recog::DBManager
- Defined in:
- lib/recog/db_manager.rb
Constant Summary collapse
- DefaultDatabasePath =
File.(File.join(File.(__dir__), ['..', '..', 'recog', '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.
12 13 14 15 |
# File 'lib/recog/db_manager.rb', line 12 def initialize(path = DefaultDatabasePath) self.path = path reload end |
Instance Attribute Details
#databases ⇒ Object
Returns the value of attribute databases.
8 9 10 |
# File 'lib/recog/db_manager.rb', line 8 def databases @databases end |
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/recog/db_manager.rb', line 8 def path @path end |
Instance Method Details
#load_databases ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/recog/db_manager.rb', line 17 def load_databases if File.directory?(path) Dir["#{path}/*.xml"].each do |dbxml| databases << DB.new(dbxml) end else databases << DB.new(path) end end |
#reload ⇒ Object
27 28 29 30 |
# File 'lib/recog/db_manager.rb', line 27 def reload self.databases = [] load_databases end |