Sha256: 58d89cb1e3eb856aa8b6cde017ec94b7272d786c14de8a48eb454611417e4dd1

Contents?: true

Size: 792 Bytes

Versions: 1

Compression:

Stored size: 792 Bytes

Contents

# frozen_string_literal: true

module Rambling
  module Trie
    module Serializers
      # Basic file serializer. Dumps/loads string contents from files.
      class File < Serializer
        # 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.write filepath, contents
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rambling-trie-2.5.0 lib/rambling/trie/serializers/file.rb