Class: SteamCodec::ACF::UserConfig
- Inherits:
-
Object
- Object
- SteamCodec::ACF::UserConfig
- Defined in:
- lib/steam_codec/acf.rb
Instance Attribute Summary collapse
-
#AppInstallDir ⇒ Object
Returns the value of attribute AppInstallDir.
-
#BetaKey ⇒ Object
Returns the value of attribute BetaKey.
-
#GameID ⇒ Object
Returns the value of attribute GameID.
-
#Installed ⇒ Object
Returns the value of attribute Installed.
-
#Language ⇒ Object
Returns the value of attribute Language.
-
#Name ⇒ Object
Returns the value of attribute Name.
Class Method Summary collapse
Instance Method Summary collapse
- #get(path = '', seperator = '.') ⇒ Object
-
#initialize(userConfig = nil) ⇒ UserConfig
constructor
A new instance of UserConfig.
- #load(userConfig) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(userConfig = nil) ⇒ UserConfig
Returns a new instance of UserConfig.
123 124 125 |
# File 'lib/steam_codec/acf.rb', line 123 def initialize(userConfig = nil) load(userConfig || KeyValues.new) end |
Instance Attribute Details
#AppInstallDir ⇒ Object
Returns the value of attribute AppInstallDir.
116 117 118 |
# File 'lib/steam_codec/acf.rb', line 116 def AppInstallDir @AppInstallDir end |
#BetaKey ⇒ Object
Returns the value of attribute BetaKey.
118 119 120 |
# File 'lib/steam_codec/acf.rb', line 118 def BetaKey @BetaKey end |
#GameID ⇒ Object
Returns the value of attribute GameID.
114 115 116 |
# File 'lib/steam_codec/acf.rb', line 114 def GameID @GameID end |
#Installed ⇒ Object
Returns the value of attribute Installed.
115 116 117 |
# File 'lib/steam_codec/acf.rb', line 115 def Installed @Installed end |
#Language ⇒ Object
Returns the value of attribute Language.
117 118 119 |
# File 'lib/steam_codec/acf.rb', line 117 def Language @Language end |
#Name ⇒ Object
Returns the value of attribute Name.
113 114 115 |
# File 'lib/steam_codec/acf.rb', line 113 def Name @Name end |
Class Method Details
.scalarFields ⇒ Object
119 120 121 |
# File 'lib/steam_codec/acf.rb', line 119 def self.scalarFields return [:Name, :GameID, :Installed, :AppInstallDir, :Language, :BetaKey] end |
Instance Method Details
#get(path = '', seperator = '.') ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/steam_codec/acf.rb', line 138 def get(path = '', seperator = '.') return nil unless @UserConfig fields = path.split(seperator) return to_hash unless fields.first self.class.scalarFields.each do |field| if field.to_s.downcase == fields.first.downcase return self.send(field) end end @UserConfig.get(path, seperator) end |
#load(userConfig) ⇒ Object
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/steam_codec/acf.rb', line 127 def load(userConfig) raise ArgumentError, "UserConfig must be instance of KeyValues" unless userConfig.is_a?(KeyValues) @UserConfig = userConfig @Name = @UserConfig.name if @UserConfig.key?(:name) @GameID = @UserConfig.gameid.to_i if @UserConfig.key?(:gameid) @Installed = !@UserConfig.installed.to_i.zero? if @UserConfig.key?(:installed) @AppInstallDir = @UserConfig.appinstalldir if @UserConfig.key?(:appinstalldir) @Language = @UserConfig.language if @UserConfig.key?(:language) @BetaKey = @UserConfig.BetaKey if @UserConfig.key?(:BetaKey) end |
#to_hash ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/steam_codec/acf.rb', line 150 def to_hash result = {} self.class.scalarFields.each do |field| result[field.to_s] = self.send(field) end result end |