Class: CARPS::SessionConfig
- Inherits:
-
UserConfig
- Object
- YamlConfig
- UserConfig
- CARPS::SessionConfig
- Defined in:
- lib/carps/service/start/config.rb
Overview
A configuration file for games which keeps track of sessions, and the mod’s saved state
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(session, filename) ⇒ SessionConfig
constructor
Create from session ID and filename.
-
#load_mod ⇒ Object
Load the mod.
- #parse_yaml(conf) ⇒ Object
-
#register_session(manager) ⇒ Object
Set the session used by a session manager.
-
#save ⇒ Object
Save this game.
-
#save_mod(mod) ⇒ Object
Save the mod.
Methods inherited from UserConfig
Methods inherited from YamlConfig
Constructor Details
#initialize(session, filename) ⇒ SessionConfig
Create from session ID and filename
27 28 29 30 |
# File 'lib/carps/service/start/config.rb', line 27 def initialize session, filename @session = session @filename = filename end |
Instance Method Details
#load_mod ⇒ Object
Load the mod
52 53 54 |
# File 'lib/carps/service/start/config.rb', line 52 def load_mod @save end |
#parse_yaml(conf) ⇒ Object
37 38 39 40 41 |
# File 'lib/carps/service/start/config.rb', line 37 def parse_yaml conf @filename = read_conf conf, "filename" @session = read_conf conf, "session" @save = conf["save"] end |
#register_session(manager) ⇒ Object
Set the session used by a session manager
33 34 35 |
# File 'lib/carps/service/start/config.rb', line 33 def register_session manager manager.session = @session end |
#save ⇒ Object
Save this game
57 58 59 |
# File 'lib/carps/service/start/config.rb', line 57 def save save_file "games/" + @filename + ".yaml" end |
#save_mod(mod) ⇒ Object
Save the mod
Also saves the file
46 47 48 49 |
# File 'lib/carps/service/start/config.rb', line 46 def save_mod mod @save = mod save end |