Last active
October 8, 2016 07:46
-
-
Save yukas/8b966414a728530269c426353692307e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConfigFile | |
FILE_PATH = 'path/to/config.cfg' | |
def write_player_state(state) | |
File.open(FILE_PATH, 'w') do |f| | |
f.write('player_state: #{state}') | |
end | |
end | |
def read_player_state | |
IO.read(FILE_PATH) | |
end | |
end | |
class Game | |
def save_player_state | |
config_file = ConfigFile.new | |
config_file.write_player_state('near_window') | |
end | |
end | |
class Player | |
def read_state | |
config_file = ConfigFile.new | |
@state = config_file.read_player_state | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment