Class: Rbdb::DB
- Inherits:
-
Object
- Object
- Rbdb::DB
- Defined in:
- lib/rbdb/db.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #create_table(name, options = {}) ⇒ Object
- #find_table(name) ⇒ Object
-
#initialize(name, options = {}) ⇒ DB
constructor
A new instance of DB.
- #table_count ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ DB
Returns a new instance of DB.
5 6 7 8 9 |
# File 'lib/rbdb/db.rb', line 5 def initialize(name, = {}) @name = name.to_s @options = @tables = Hash.new end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rbdb/db.rb', line 3 def name @name end |
#tables ⇒ Object (readonly)
Returns the value of attribute tables.
3 4 5 |
# File 'lib/rbdb/db.rb', line 3 def tables @tables end |
Instance Method Details
#[](name) ⇒ Object
26 27 28 |
# File 'lib/rbdb/db.rb', line 26 def [](name) find_table(name) end |
#create_table(name, options = {}) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/rbdb/db.rb', line 15 def create_table(name, = {}) Rbdb::Util.check_existence_and_force(@tables.keys, name, ) do table = Rbdb::Table.new(name) @tables[name] = table end end |
#find_table(name) ⇒ Object
22 23 24 |
# File 'lib/rbdb/db.rb', line 22 def find_table(name) @tables[name] end |
#table_count ⇒ Object
11 12 13 |
# File 'lib/rbdb/db.rb', line 11 def table_count @tables.length end |