Class: StarCitizen::Config
- Inherits:
-
Object
- Object
- StarCitizen::Config
- Defined in:
- lib/starcitizen/config.rb
Overview
Configuration for starcitizen-tools.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Config file path.
Class Method Summary collapse
-
.game_path ⇒ Object
Location of Star Citizen.
Instance Method Summary collapse
-
#game_path ⇒ Object
Location of Star Citizen.
-
#initialize(**kwargs) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(**kwargs) ⇒ Config
Returns a new instance of Config.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/starcitizen/config.rb', line 18 def initialize **kwargs @path = File. kwargs.fetch(:path, '~/starcitizen-tools.cfg.yaml') # Create config file. unless File.exists? @path begin require 'win32/registry' game_path = File.dirname Win32::Registry::HKEY_CURRENT_USER .open('Software\Cloud Imperium Games\StarCitizen')['UninstallString'] rescue LoadError # Not Windows game_path = File. '~/.wine/drive_c/Program Files/StarCitizen' end File.open(@path, 'w') do |f| f.write({ 'game_path' => game_path }.to_yaml) end end @config = YAML.load_file @path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Config file path.
15 16 17 |
# File 'lib/starcitizen/config.rb', line 15 def path @path end |
Class Method Details
.game_path ⇒ Object
Location of Star Citizen.
9 10 11 |
# File 'lib/starcitizen/config.rb', line 9 def self.game_path new.game_path end |
Instance Method Details
#game_path ⇒ Object
Location of Star Citizen.
40 41 42 |
# File 'lib/starcitizen/config.rb', line 40 def game_path @config['game_path'].gsub('\\', '/') end |