Class: StrokeDB::InvertedListFileStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/strokedb/stores/inverted_list_file_storage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ InvertedListFileStorage

Returns a new instance of InvertedListFileStorage.



8
9
10
11
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 8

def initialize(opts={})
  opts = opts.stringify_keys 
  @path = opts['path']
end

Instance Attribute Details

#pathObject

TODO: include ChainableStorage



6
7
8
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 6

def path
  @path
end

Instance Method Details

#clear!Object



17
18
19
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 17

def clear!
  FileUtils.rm_rf @path
end

#find_listObject



13
14
15
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 13

def find_list
  read(file_path)
end

#save!(list) ⇒ Object



21
22
23
24
# File 'lib/strokedb/stores/inverted_list_file_storage.rb', line 21

def save!(list)
  FileUtils.mkdir_p @path
  write(file_path, list)
end