Class: Rbdb::DB

Inherits:
Object
  • Object
show all
Defined in:
lib/rbdb/db.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @name = name.to_s
  @options = options
  @tables = Hash.new
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rbdb/db.rb', line 3

def name
  @name
end

#tablesObject (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, options = {})
  Rbdb::Util.check_existence_and_force(@tables.keys, name, options) 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_countObject



11
12
13
# File 'lib/rbdb/db.rb', line 11

def table_count
  @tables.length
end