Module: Inform::Game

Defined in:
lib/runtime/game.rb,
lib/runtime/game_loader.rb

Overview

The Game module

Defined Under Namespace

Modules: Loader Classes: GameLoadError

Class Method Summary collapse

Class Method Details

.configObject



41
42
43
# File 'lib/runtime/game.rb', line 41

def config
  @config
end

.environmentObject



46
47
48
# File 'lib/runtime/game.rb', line 46

def environment
  (ENV['GAME_ENVIRONMENT'] || config[:environment] || Inform::Runtime.default_environment).to_sym
end

.environment=(env) ⇒ Object



51
52
53
# File 'lib/runtime/game.rb', line 51

def environment=(env)
  config[:environment] = env.to_sym
end

.game_config_file_path(path) ⇒ Object



58
59
60
# File 'lib/runtime/game.rb', line 58

def game_config_file_path(path)
  File.join(path, 'config.yml')
end

.game_dir_path(path) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/runtime/game.rb', line 63

def game_dir_path(path)
  return path if File.directory?(path)
  Inform::Game.config[:game_file_path] = path
  game_dir_path = File.expand_path(File.dirname(path))
  return game_dir_path if File.exist?(game_config_file_path(game_dir_path))
  Inform::Runtime.default_game_dir_path
end

.init(options) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/runtime/game.rb', line 31

def init(options)
  Inform::Game.config[:game_path] = game_dir_path(options[:game_path])
  Inform::Game.config[:game_config_file_path] =
    game_config_file_path(Inform::Game.config[:game_path])
  Inform::Game.config.update(
    YAML.load_file(Inform::Game.config[:game_config_file_path], symbolize_names: true)
  )
end