Skip to content

Instantly share code, notes, and snippets.

@yukas
Last active October 8, 2016 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukas/8b966414a728530269c426353692307e to your computer and use it in GitHub Desktop.
Save yukas/8b966414a728530269c426353692307e to your computer and use it in GitHub Desktop.
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