Class: StoryTeller::Game

Inherits:
Object show all
Defined in:
lib/story_teller/game/loader.rb

Overview

The Game class

Defined Under Namespace

Modules: Loader Classes: GameLoadError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Game

Returns a new instance of Game.



30
31
32
33
34
35
36
# File 'lib/story_teller/game/loader.rb', line 30

def initialize(options)
  @config = {}
  @path, @file_path = game_paths(options)
  @config_file_path = File.join(@path, options[:game_config_file_name])
  @config = YAML.load_file(@config_file_path, symbolize_names: true)
  @config[:game_file_path] = @file_path unless @file_path.nil?
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



28
29
30
# File 'lib/story_teller/game/loader.rb', line 28

def config
  @config
end

#config_file_pathObject (readonly)

Returns the value of attribute config_file_path.



28
29
30
# File 'lib/story_teller/game/loader.rb', line 28

def config_file_path
  @config_file_path
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



28
29
30
# File 'lib/story_teller/game/loader.rb', line 28

def file_path
  @file_path
end

#pathObject (readonly)

Returns the value of attribute path.



28
29
30
# File 'lib/story_teller/game/loader.rb', line 28

def path
  @path
end

Instance Method Details

#environmentObject



42
43
44
45
46
47
48
# File 'lib/story_teller/game/loader.rb', line 42

def environment
  (
    ENV['GAME_ENVIRONMENT'] ||
    @config[:environment] ||
    StoryTeller::Engine.default_environment
  ).to_sym
end

#environment=(env) ⇒ Object



50
51
52
# File 'lib/story_teller/game/loader.rb', line 50

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

#nameObject



38
39
40
# File 'lib/story_teller/game/loader.rb', line 38

def name
  @config[:game_name]
end