Class: Vimdb::DB
- Inherits:
-
Object
- Object
- Vimdb::DB
- Defined in:
- lib/vimdb/db.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize(file = ENV['VIMDB_DB'] || Dir.home + '/.vimdb.pstore') ⇒ DB
constructor
A new instance of DB.
- #set(key, value) ⇒ Object
Constructor Details
#initialize(file = ENV['VIMDB_DB'] || Dir.home + '/.vimdb.pstore') ⇒ DB
Returns a new instance of DB.
6 7 8 9 |
# File 'lib/vimdb/db.rb', line 6 def initialize(file = ENV['VIMDB_DB'] || Dir.home + '/.vimdb.pstore') @file = file @db = PStore.new(@file) end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
5 6 7 |
# File 'lib/vimdb/db.rb', line 5 def file @file end |
Instance Method Details
#get(key) ⇒ Object
11 12 13 |
# File 'lib/vimdb/db.rb', line 11 def get(key) @db.transaction(true) { @db[key] } end |
#set(key, value) ⇒ Object
15 16 17 |
# File 'lib/vimdb/db.rb', line 15 def set(key, value) @db.transaction { @db[key] = value } end |