Module: Chess::Save::Serializer

Included in:
Chess::Save
Defined in:
lib/chess/save/serializer.rb

Overview

Serializer for saving to file and reading from file.

Constant Summary collapse

SERIALIZER =

Serializing format used for save and load

JSON

Instance Method Summary collapse

Instance Method Details

#serialize(data) ⇒ String

serializes the save data with save_name as keys and FEN as values

Parameters:

  • data (Hash)

Returns:

  • (String)


16
17
18
# File 'lib/chess/save/serializer.rb', line 16

def serialize(data)
  SERIALIZER.dump data
end

#unserialize(string) ⇒ Hash

unserializes the given string and returns the Hash with save’s name as keys and FEN code as values.

Returns:

  • (Hash)


24
25
26
# File 'lib/chess/save/serializer.rb', line 24

def unserialize(string)
  SERIALIZER.parse string
end