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
-
#serialize(data) ⇒ String
serializes the save data with save_name as keys and FEN as values.
-
#unserialize(string) ⇒ Hash
unserializes the given string and returns the Hash with save’s name as keys and FEN code as values.
Instance Method Details
#serialize(data) ⇒ String
serializes the save data with save_name as keys and FEN as values
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.
24 25 26 |
# File 'lib/chess/save/serializer.rb', line 24 def unserialize(string) SERIALIZER.parse string end |