Class: Modsvaskr::Config
- Inherits:
-
Object
- Object
- Modsvaskr::Config
- Defined in:
- lib/modsvaskr/config.rb
Overview
Configuration
Instance Method Summary collapse
-
#auto_keys ⇒ Object
Return the automated keys to apply.
-
#games ⇒ Object
Get the games list.
-
#initialize(file) ⇒ Config
constructor
Constructor.
-
#no_prompt ⇒ Object
Return the no_prompt flag.
-
#seven_zip_path ⇒ Object
Return the 7-Zip path.
-
#xedit_path ⇒ Object
Return the xEdit path.
Constructor Details
#initialize(file) ⇒ Config
Constructor
- Parameters
-
file (String): File containing configuration
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/modsvaskr/config.rb', line 14 def initialize(file) @config = YAML.safe_load(File.read(file)) || {} # Parse all game types plugins # Hash<Symbol, Class> @game_types = Dir.glob("#{__dir__}/games/*.rb").to_h do |game_type_file| require game_type_file base_name = File.basename(game_type_file, '.rb') [ base_name.to_sym, Games.const_get(base_name.split('_').collect(&:capitalize).join.to_sym) ] end end |
Instance Method Details
#auto_keys ⇒ Object
Return the automated keys to apply
- Result
-
Array<String>: The list of automated keys
64 65 66 |
# File 'lib/modsvaskr/config.rb', line 64 def auto_keys @config['auto_keys'] || [] end |
#games ⇒ Object
Get the games list
- Result
-
Array<Game>: List of games
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/modsvaskr/config.rb', line 32 def games unless defined?(@games) @games = (@config['games'] || []).map do |game_info| game_type = game_info['type'].to_sym raise "Unknown game type: #{game_type}. Available ones are #{@game_types.keys.join(', ')}" unless @game_types.key?(game_type) @game_types[game_type].new(self, game_info) end end @games end |
#no_prompt ⇒ Object
Return the no_prompt flag
- Result
-
Boolean: no_prompt flag
72 73 74 |
# File 'lib/modsvaskr/config.rb', line 72 def no_prompt @config['no_prompt'] || false end |
#seven_zip_path ⇒ Object
Return the 7-Zip path
- Result
-
String: The 7-Zip path
56 57 58 |
# File 'lib/modsvaskr/config.rb', line 56 def seven_zip_path @config['7zip'] end |
#xedit_path ⇒ Object
Return the xEdit path
- Result
-
String: The xEdit path
48 49 50 |
# File 'lib/modsvaskr/config.rb', line 48 def xedit_path @config['xedit'] end |