Class: Rambling::Trie::Serializers::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/rambling/trie/serializers/serializer.rb

Overview

Base class for all serializers.

Direct Known Subclasses

File, Marshal, Yaml, Zip

Instance Method Summary collapse

Instance Method Details

#dump(contents, filepath) ⇒ Numeric

This method is abstract.

Subclass and override #dump to output the desired format.

Dumps contents into a specified filepath.

Parameters:

  • contents (TContents)

    the contents to dump into given file.

  • filepath (String)

    the filepath to dump the contents to.

Returns:

  • (Numeric)

    number of bytes written to disk.

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/rambling/trie/serializers/serializer.rb', line 21

def dump contents, filepath
  raise NotImplementedError
end

#load(filepath) ⇒ TContents

This method is abstract.

Subclass and override #load to parse the desired format.

Loads contents from a specified filepath.

Parameters:

  • filepath (String)

    the filepath to load contents from.

Returns:

  • (TContents)

    parsed contents from given file.

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/rambling/trie/serializers/serializer.rb', line 12

def load filepath
  raise NotImplementedError
end