Class: Metro::SetupHandlers::ParseAndLoadGameConfiguration
- Inherits:
-
Object
- Object
- Metro::SetupHandlers::ParseAndLoadGameConfiguration
- Defined in:
- lib/setup_handlers/load_game_configuration.rb
Overview
Loads the game configuration information and sets up a Game object with the content loaded from the game configuration.
Instance Method Summary collapse
Instance Method Details
#game_file_exists?(file) ⇒ Boolean
46 47 48 49 |
# File 'lib/setup_handlers/load_game_configuration.rb', line 46 def game_file_exists?(file) error!("error.missing_metro_file",file: file) unless File.exists?(file) error!("error.specified_directory",directory: file) if File.directory?(file) end |
#game_files_exist!(*files) ⇒ Object
42 43 44 |
# File 'lib/setup_handlers/load_game_configuration.rb', line 42 def game_files_exist!(*files) files.compact.flatten.each { |file| game_file_exists?(file) } end |
#setup(options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/setup_handlers/load_game_configuration.rb', line 29 def setup() filename = .filename Game.execution_parameters = .execution_parameters gamefile = File.basename(filename) game_files_exist!(gamefile) game_contents = File.read(gamefile) game_block = lambda {|instance| eval(game_contents) } game = Game::DSL.parse(&game_block) Game.setup game end |