Class: RgssDb::DataFileHashNumber
- Inherits:
-
DataFileHash
- Object
- DataFile
- DataFileHash
- RgssDb::DataFileHashNumber
- Defined in:
- lib/rgss_db/model/data_file.rb
Overview
RPG Maker numbered hash data file
This class expects the object to be a hash
This class forces hash keys to be a number for the data files:
-
Areas
-
MapInfos
**Reason: Creating a DataFileHash instance from a MapInfos/Areas JSON file provokes undesired behavior.**
JSON only allows key names to be strings, so all keys of the hash will be converted to string.
This is undesired behavior because RPG Maker editor requires the MapInfos and Areas hash keys to be numbers.
So we need to convert all keys read from the JSON file to integers when importing the JSON file into the RPG Maker database, hence the inclusion of this class specification from DataFileHash.
Otherwise the RPG Maker editor will fail to show the maps and areas even though data still exists.
Instance Attribute Summary
Attributes inherited from DataFileHash
Attributes inherited from DataFile
#file_path, #object, #object_ids, #type
Instance Method Summary collapse
-
#serialize ⇒ Hash
Serializes the data file’s object.
Methods inherited from DataFileHash
#all_objects?, #convert_list_to_ids, #merge, #to_list, #to_merge
Methods inherited from DataFile
#<=>, #all_objects?, #convert_list_to_ids, #customizable?, #file, #file?, #file_path?, #initialize, #merge, #mergeable?, #object_ids_clear, #object_ids_update, #serialize_file_name, #to_list, #to_merge, #to_s, #type?
Constructor Details
This class inherits a constructor from RgssDb::DataFile
Instance Method Details
#serialize ⇒ Hash
Serializes the data file’s object
This method prepares the object as a hash
Object IDs list is used to filter the correct
510 511 512 513 514 |
# File 'lib/rgss_db/model/data_file.rb', line 510 def serialize super.transform_keys do |key| key.to_s.to_i end end |