Class Irc::DBHash
In: lib/rbot/registry/bdb.rb
lib/rbot/registry/tc.rb
Parent: Object
BasicUserMessage JoinMessage NamesMessage WhoisMessage ModeChangeMessage KickMessage MotdMessage QuitMessage BanlistMessage UserMessage NoSuchTargetMessage TopicMessage NickMessage WelcomeMessage UnknownMessage InviteMessage PartMessage NetmaskList UserList ArrayOf ChannelList Netmask User\n[lib/rbot/botuser.rb\nlib/rbot/irc.rb] Channel Singleton RfcCasemap StrictRfcCasemap AsciiCasemap Casemap PrivMessage NoticeMessage TokyoCabinet::BDB CIBDB Btree CIBtree Socket MessageQueue QueueRing Client DBHash\n[lib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] DBTree\n[lib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] Server NetmaskDb Bot\n[lib/rbot/botuser.rb\nlib/rbot/config.rb\nlib/rbot/ircbot.rb\nlib/rbot/language.rb\nlib/rbot/message.rb\nlib/rbot/messagemapper.rb\nlib/rbot/plugins.rb\nlib/rbot/rbotconfig.rb\nlib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] lib/rbot/ircsocket.rb lib/rbot/rfc2812.rb lib/rbot/registry/tc.rb lib/rbot/irc.rb lib/rbot/maskdb.rb lib/rbot/message.rb lib/rbot/messagemapper.rb lib/rbot/botuser.rb lib/rbot/registry/tc.rb (null) BotConfig PKGConfig ServerOrCasemap Irc dot/m_35_0.png

DBHash is for tying a hash to disk (using bdb). Call it with an identifier, for example "mydata". It‘ll look for mydata.db, if it exists, it will load and reference that db. Otherwise it‘ll create and empty db called mydata.db

Methods

Public Class methods

[Source]

    # File lib/rbot/registry/bdb.rb, line 76
76:     def DBHash.create_db(name)
77:       debug "DBHash: creating empty db #{name}"
78:       return BDB::Hash.open(name, nil,
79:       BDB::CREATE | BDB::EXCL, 0600)
80:     end

[Source]

    # File lib/rbot/registry/tc.rb, line 64
64:     def DBHash.create_db(name)
65:       debug "DBHash: creating empty db #{name}"
66:       return BDB::Hash.open(name, nil,
67:       BDB::CREATE | BDB::EXCL, 0600)
68:     end
absfilename:use key as an actual filename, don‘t prepend the bot‘s config path and don‘t append ".db"

[Source]

    # File lib/rbot/registry/bdb.rb, line 52
52:     def initialize(bot, key, absfilename=false)
53:       @bot = bot
54:       @key = key
55:       relfilename = @bot.path key
56:       relfilename << '.db'
57:       if absfilename && File.exist?(key)
58:         # db already exists, use it
59:         @db = DBHash.open_db(key)
60:       elsif absfilename
61:         # create empty db
62:         @db = DBHash.create_db(key)
63:       elsif File.exist? relfilename
64:         # db already exists, use it
65:         @db = DBHash.open_db relfilename
66:       else
67:         # create empty db
68:         @db = DBHash.create_db relfilename
69:       end
70:     end
absfilename:use key as an actual filename, don‘t prepend the bot‘s config path and don‘t append ".db"

[Source]

    # File lib/rbot/registry/tc.rb, line 40
40:     def initialize(bot, key, absfilename=false)
41:       @bot = bot
42:       @key = key
43:       relfilename = @bot.path key
44:       relfilename << '.db'
45:       if absfilename && File.exist?(key)
46:         # db already exists, use it
47:         @db = DBHash.open_db(key)
48:       elsif absfilename
49:         # create empty db
50:         @db = DBHash.create_db(key)
51:       elsif File.exist? relfilename
52:         # db already exists, use it
53:         @db = DBHash.open_db relfilename
54:       else
55:         # create empty db
56:         @db = DBHash.create_db relfilename
57:       end
58:     end

[Source]

    # File lib/rbot/registry/bdb.rb, line 82
82:     def DBHash.open_db(name)
83:       debug "DBHash: opening existing db #{name}"
84:       return BDB::Hash.open(name, nil, "r+", 0600)
85:     end

[Source]

    # File lib/rbot/registry/tc.rb, line 70
70:     def DBHash.open_db(name)
71:       debug "DBHash: opening existing db #{name}"
72:       return BDB::Hash.open(name, nil, "r+", 0600)
73:     end

Public Instance methods

[Source]

    # File lib/rbot/registry/bdb.rb, line 72
72:     def method_missing(method, *args, &block)
73:       return @db.send(method, *args, &block)
74:     end

[Source]

    # File lib/rbot/registry/tc.rb, line 60
60:     def method_missing(method, *args, &block)
61:       return @db.send(method, *args, &block)
62:     end

[Validate]