class AnyStyle::Dictionary::GDBM
Attributes
env[R]
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
AnyStyle::Dictionary::new
# File lib/anystyle/dictionary/gdbm.rb 14 def initialize(options = {}) 15 super(self.class.defaults.merge(options)) 16 end
Public Instance Methods
close()
click to toggle source
# File lib/anystyle/dictionary/gdbm.rb 26 def close 27 db.close if open? 28 end
empty?()
click to toggle source
# File lib/anystyle/dictionary/gdbm.rb 34 def empty? 35 open? and db.empty? 36 end
get(key)
click to toggle source
# File lib/anystyle/dictionary/gdbm.rb 43 def get(key) 44 db[key.to_s].to_i 45 end
open()
click to toggle source
# File lib/anystyle/dictionary/gdbm.rb 18 def open 19 close 20 @db = ::GDBM.new(*options.values_at(:path, :mode, :flags)) 21 self 22 ensure 23 populate! if empty? 24 end
open?()
click to toggle source
# File lib/anystyle/dictionary/gdbm.rb 30 def open? 31 !(db.nil? || db.closed?) 32 end
put(key, value)
click to toggle source
# File lib/anystyle/dictionary/gdbm.rb 47 def put(key, value) 48 db[key.to_s] = value.to_i.to_s 49 end
truncate()
click to toggle source
# File lib/anystyle/dictionary/gdbm.rb 38 def truncate 39 close 40 File.unlink(options[:path]) 41 end