Module: Jruby::Mapdb::ClassMethods
Instance Method Summary collapse
- #decode(key) ⇒ Object (also: #[])
- #each ⇒ Object
- #encode(key, value) ⇒ Object (also: #[]=)
- #keys ⇒ Object
- #regexp(pattern) ⇒ Object
Instance Method Details
#decode(key) ⇒ Object Also known as: []
11 12 13 14 15 |
# File 'lib/jruby/mapdb.rb', line 11 def decode(key) stored = @tree.get(key) return nil if stored.nil? Marshal.load String.from_java_bytes(stored) end |
#each ⇒ Object
16 17 18 |
# File 'lib/jruby/mapdb.rb', line 16 def each @tree.each_pair { |key,value| yield(key, Marshal.load(String.from_java_bytes(value))) } end |
#encode(key, value) ⇒ Object Also known as: []=
8 9 10 |
# File 'lib/jruby/mapdb.rb', line 8 def encode(key, value) @tree.put key, Marshal.dump(value).to_java_bytes end |
#keys ⇒ Object
19 20 21 |
# File 'lib/jruby/mapdb.rb', line 19 def keys @tree.key_set.to_a end |
#regexp(pattern) ⇒ Object
22 23 24 25 |
# File 'lib/jruby/mapdb.rb', line 22 def regexp(pattern) re = Regexp.new "#{pattern}", Regexp::EXTENDED | Regexp::IGNORECASE @tree.select{ |k,v| "#{k}" =~ re }.map(&:first) end |