Sha256: 99ee0df023bb6b4abca13435674d489ffacf71dbd7c92636c244baf652458638

Contents?: true

Size: 793 Bytes

Versions: 4

Compression:

Stored size: 793 Bytes

Contents

module Rambling
  module Trie
    module Serializers
      # Basic file serializer. Dumps/loads string contents from files.
      class File
        # Loads contents from a specified filepath.
        # @param [String] filepath the filepath to load contents from.
        # @return [String] all contents of the file.
        def load filepath
          ::File.read filepath
        end

        # 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.
        def dump contents, filepath
          ::File.open filepath, 'w+' do |f|
            f.write contents
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rambling-trie-1.0.3 lib/rambling/trie/serializers/file.rb
rambling-trie-1.0.2 lib/rambling/trie/serializers/file.rb
rambling-trie-1.0.1 lib/rambling/trie/serializers/file.rb
rambling-trie-1.0.0 lib/rambling/trie/serializers/file.rb