Class: Vimdb::DB

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fileObject

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