Class: LevelDB::DB
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#pathname ⇒ Object
readonly
Returns the value of attribute pathname.
Class Method Summary collapse
-
.create(pathname, options = {}) ⇒ Object
Creates a new LevelDB database stored on disk at
pathname
. -
.load(pathname) ⇒ Object
Loads a LevelDB database stored on disk at
pathname
. -
.new(pathname, options = {}) ⇒ Object
Loads or creates a LevelDB database as necessary, stored on disk at
pathname
.
Instance Method Summary collapse
- #each(*args, &block) ⇒ Object
- #inspect ⇒ Object
- #iterator(*args) ⇒ Object
- #keys ⇒ Object
- #values ⇒ Object
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
43 44 45 |
# File 'lib/leveldb.rb', line 43 def @options end |
#pathname ⇒ Object (readonly)
Returns the value of attribute pathname.
42 43 44 |
# File 'lib/leveldb.rb', line 42 def pathname @pathname end |
Class Method Details
.create(pathname, options = {}) ⇒ Object
Creates a new LevelDB database stored on disk at pathname
. Throws an exception if the database already exists.
See #make for possible options.
21 22 23 24 25 |
# File 'lib/leveldb.rb', line 21 def create pathname, ={} make path_string(pathname), .merge(:create_if_missing => true, :error_if_exists => true) end |
.load(pathname) ⇒ Object
Loads a LevelDB database stored on disk at pathname
. Throws an exception unless the database already exists.
29 30 31 32 |
# File 'lib/leveldb.rb', line 29 def load pathname make path_string(pathname), { :create_if_missing => false, :error_if_exists => false } end |
.new(pathname, options = {}) ⇒ Object
Loads or creates a LevelDB database as necessary, stored on disk at pathname
.
See #make for possible options.
11 12 13 14 15 |
# File 'lib/leveldb.rb', line 11 def new pathname, ={} make path_string(pathname), .merge(:create_if_missing => true, :error_if_exists => false) end |
Instance Method Details
#each(*args, &block) ⇒ Object
52 53 54 55 56 |
# File 'lib/leveldb.rb', line 52 def each(*args, &block) i = iterator(*args) i.each(&block) if block i end |
#inspect ⇒ Object
62 63 64 |
# File 'lib/leveldb.rb', line 62 def inspect %(<#{self.class} #{@pathname.inspect}>) end |
#iterator(*args) ⇒ Object
58 |
# File 'lib/leveldb.rb', line 58 def iterator(*args); Iterator.new self, *args end |
#keys ⇒ Object
59 |
# File 'lib/leveldb.rb', line 59 def keys; map { |k, v| k } end |
#values ⇒ Object
60 |
# File 'lib/leveldb.rb', line 60 def values; map { |k, v| v } end |