class Rambling::Trie::Serializers::File

Basic file serializer. Dumps/loads string contents from files.

Public Instance Methods

dump(contents, filepath) click to toggle source

Dumps contents into a specified filepath. @param [String] contents the contents to dump. @param [String] filepath the filepath to dump the contents to. @return [Numeric] number of bytes written to disk.

# File lib/rambling/trie/serializers/file.rb, line 19
def dump contents, filepath
  ::File.open filepath, 'w+' do |f|
    f.write contents
  end
end
load(filepath) click to toggle source

Loads contents from a specified filepath. @param [String] filepath the filepath to load contents from. @return [String] all contents of the file.

# File lib/rambling/trie/serializers/file.rb, line 11
def load filepath
  ::File.read filepath
end