Module: RBStarbound
- Defined in:
- lib/rbstarbound.rb,
lib/rbstarbound/sbon.rb,
lib/rbstarbound/utils.rb,
lib/rbstarbound/player.rb,
lib/rbstarbound/sbvj01.rb,
lib/rbstarbound/version.rb,
lib/rbstarbound/sbasset6.rb,
lib/rbstarbound/exceptions.rb,
lib/rbstarbound/exit_codes.rb,
lib/rbstarbound/main_command.rb,
lib/rbstarbound/commands/dump.rb,
lib/rbstarbound/commands/export.rb,
lib/rbstarbound/commands/serialize.rb
Defined Under Namespace
Modules: Player, SBAsset6, SBON, SBVJ01
Classes: DumpCommand, ExportCommand, MainCommand, NotImplementedError, SBAsset6Error, SBVJ01Error, SerializeCommand, ValueError
Constant Summary
collapse
- VERSION =
'0.3.1'
- EX_OK =
0
- EX_ERR =
1
Class Method Summary
collapse
Class Method Details
.dump_player_save_file(path, player_data) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rbstarbound.rb', line 25
def self.dump_player_save_file(path, player_data)
save_file = File.open(path, 'wb')
SBVJ01.dump(save_file, player_data)
rescue StandardError => e
print_error(e)
return false
else
return true
ensure
save_file.close unless save_file.nil?
end
|
.parse_player_save_file(path) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/rbstarbound.rb', line 13
def self.parse_player_save_file(path)
save_file = File.open(path, 'rb')
parsed_data = SBVJ01.parse(save_file)
rescue StandardError => e
print_error(e)
return nil
else
return parsed_data
ensure
save_file.close unless save_file.nil?
end
|
.print_error(error) ⇒ Object
4
5
6
|
# File 'lib/rbstarbound/utils.rb', line 4
def self.print_error(error)
puts 'An error occured: ' + error.message
end
|