Class: SteamCodec::ACF
- Inherits:
-
Object
- Object
- SteamCodec::ACF
- Defined in:
- lib/steam_codec/acf.rb
Defined Under Namespace
Classes: CheckGuid, InstallScripts, MountedDepots, SharedDepots, UserConfig
Instance Attribute Summary collapse
-
#AppID ⇒ Object
More about AppID => https://developer.valvesoftware.com/wiki/Steam_Application_IDs.
-
#BuildID ⇒ Object
Returns the value of attribute BuildID.
-
#BytesDownloaded ⇒ Object
Returns the value of attribute BytesDownloaded.
-
#BytesToDownload ⇒ Object
Returns the value of attribute BytesToDownload.
-
#CheckGuid ⇒ Object
readonly
Returns the value of attribute CheckGuid.
-
#FullValidateOnNextUpdate ⇒ Object
Returns the value of attribute FullValidateOnNextUpdate.
-
#InstallDir ⇒ Object
Returns the value of attribute InstallDir.
-
#InstallScripts ⇒ Object
readonly
Returns the value of attribute InstallScripts.
-
#LastOwner ⇒ Object
Returns the value of attribute LastOwner.
-
#LastUpdated ⇒ Object
Returns the value of attribute LastUpdated.
-
#MountedDepots ⇒ Object
readonly
Returns the value of attribute MountedDepots.
-
#SharedDepots ⇒ Object
readonly
Returns the value of attribute SharedDepots.
-
#SizeOnDisk ⇒ Object
Returns the value of attribute SizeOnDisk.
-
#StateFlags ⇒ Object
Returns the value of attribute StateFlags.
-
#Universe ⇒ Object
Returns the value of attribute Universe.
-
#UpdateResult ⇒ Object
Returns the value of attribute UpdateResult.
-
#UserConfig ⇒ Object
readonly
Returns the value of attribute UserConfig.
Class Method Summary collapse
Instance Method Summary collapse
- #get(path = '', seperator = '.') ⇒ Object
-
#initialize(appState = nil) ⇒ ACF
constructor
A new instance of ACF.
- #load(appState) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
Instance Attribute Details
#AppID ⇒ Object
More about AppID => https://developer.valvesoftware.com/wiki/Steam_Application_IDs
6 7 8 |
# File 'lib/steam_codec/acf.rb', line 6 def AppID @AppID end |
#BuildID ⇒ Object
Returns the value of attribute BuildID.
13 14 15 |
# File 'lib/steam_codec/acf.rb', line 13 def BuildID @BuildID end |
#BytesDownloaded ⇒ Object
Returns the value of attribute BytesDownloaded.
16 17 18 |
# File 'lib/steam_codec/acf.rb', line 16 def BytesDownloaded @BytesDownloaded end |
#BytesToDownload ⇒ Object
Returns the value of attribute BytesToDownload.
15 16 17 |
# File 'lib/steam_codec/acf.rb', line 15 def BytesToDownload @BytesToDownload end |
#CheckGuid ⇒ Object (readonly)
Returns the value of attribute CheckGuid.
21 22 23 |
# File 'lib/steam_codec/acf.rb', line 21 def CheckGuid @CheckGuid end |
#FullValidateOnNextUpdate ⇒ Object
Returns the value of attribute FullValidateOnNextUpdate.
17 18 19 |
# File 'lib/steam_codec/acf.rb', line 17 def FullValidateOnNextUpdate @FullValidateOnNextUpdate end |
#InstallDir ⇒ Object
Returns the value of attribute InstallDir.
9 10 11 |
# File 'lib/steam_codec/acf.rb', line 9 def InstallDir @InstallDir end |
#InstallScripts ⇒ Object (readonly)
Returns the value of attribute InstallScripts.
22 23 24 |
# File 'lib/steam_codec/acf.rb', line 22 def InstallScripts @InstallScripts end |
#LastOwner ⇒ Object
Returns the value of attribute LastOwner.
14 15 16 |
# File 'lib/steam_codec/acf.rb', line 14 def LastOwner @LastOwner end |
#LastUpdated ⇒ Object
Returns the value of attribute LastUpdated.
10 11 12 |
# File 'lib/steam_codec/acf.rb', line 10 def LastUpdated @LastUpdated end |
#MountedDepots ⇒ Object (readonly)
Returns the value of attribute MountedDepots.
19 20 21 |
# File 'lib/steam_codec/acf.rb', line 19 def MountedDepots @MountedDepots end |
#SharedDepots ⇒ Object (readonly)
Returns the value of attribute SharedDepots.
20 21 22 |
# File 'lib/steam_codec/acf.rb', line 20 def SharedDepots @SharedDepots end |
#SizeOnDisk ⇒ Object
Returns the value of attribute SizeOnDisk.
12 13 14 |
# File 'lib/steam_codec/acf.rb', line 12 def SizeOnDisk @SizeOnDisk end |
#StateFlags ⇒ Object
Returns the value of attribute StateFlags.
8 9 10 |
# File 'lib/steam_codec/acf.rb', line 8 def StateFlags @StateFlags end |
#Universe ⇒ Object
Returns the value of attribute Universe.
7 8 9 |
# File 'lib/steam_codec/acf.rb', line 7 def Universe @Universe end |
#UpdateResult ⇒ Object
Returns the value of attribute UpdateResult.
11 12 13 |
# File 'lib/steam_codec/acf.rb', line 11 def UpdateResult @UpdateResult end |
#UserConfig ⇒ Object (readonly)
Returns the value of attribute UserConfig.
18 19 20 |
# File 'lib/steam_codec/acf.rb', line 18 def UserConfig @UserConfig end |
Class Method Details
.extendedFields ⇒ Object
30 31 32 |
# File 'lib/steam_codec/acf.rb', line 30 def self.extendedFields return [:UserConfig, :MountedDepots, :SharedDepots, :CheckGuid, :InstallScripts] end |
.load(data) ⇒ Object
40 41 42 43 44 |
# File 'lib/steam_codec/acf.rb', line 40 def self.load(data) acf = KeyValues::load(data) return self.new(acf.AppState) if acf and acf.key?(:AppState) nil end |
.loadFromFile(file) ⇒ Object
34 35 36 37 38 |
# File 'lib/steam_codec/acf.rb', line 34 def self.loadFromFile(file) acf = KeyValues::loadFromFile(file) return self.new(acf.AppState) if acf and acf.key?(:AppState) nil end |
.scalarFields ⇒ Object
23 24 25 26 27 28 |
# File 'lib/steam_codec/acf.rb', line 23 def self.scalarFields return [:AppID, :Universe, :StateFlags, :InstallDir, :LastUpdated, :UpdateResult, :SizeOnDisk, :BuildID, :LastOwner, :BytesToDownload, :BytesDownloaded, :FullValidateOnNextUpdate] end |
Instance Method Details
#get(path = '', seperator = '.') ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/steam_codec/acf.rb', line 81 def get(path = '', seperator = '.') return nil unless @AppState fields = path.split(seperator) first = fields.shift return to_hash unless first self.class.scalarFields.each do |field| if field.to_s.downcase == first.downcase return self.send(field) end end self.class.extendedFields.each do |field| if field.to_s.downcase == first.downcase return self.send(field).to_hash if fields.count == 0 return self.send(field).get(fields.join(seperator), seperator) end end @AppState.get(path, seperator) end |
#load(appState) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/steam_codec/acf.rb', line 50 def load(appState) raise ArgumentError, "AppState must be instance of KeyValues" unless appState.is_a?(KeyValues) @AppState = appState @AppID = @AppState.AppID.to_i if @AppState.key?(:AppID) @Universe = @AppState.Universe.to_i if @AppState.key?(:Universe) @StateFlags = @AppState.StateFlags.to_i if @AppState.key?(:StateFlags) @InstallDir = @AppState.InstallDir if @AppState.key?(:InstallDir) @LastUpdated = @AppState.LastUpdated.to_i if @AppState.key?(:LastUpdated) @UpdateResult = @AppState.UpdateResult.to_i if @AppState.key?(:UpdateResult) @SizeOnDisk = @AppState.SizeOnDisk.to_i if @AppState.key?(:SizeOnDisk) @BuildID = @AppState.BuildID.to_i if @AppState.key?(:BuildID) @LastOwner = @AppState.LastOwner if @AppState.key?(:LastOwner) @BytesToDownload = @AppState.BytesToDownload.to_i if @AppState.key?(:BytesToDownload) @BytesDownloaded = @AppState.BytesDownloaded.to_i if @AppState.key?(:BytesDownloaded) @FullValidateOnNextUpdate = !@AppState.FullValidateOnNextUpdate.to_i.zero? if @AppState.key?(:FullValidateOnNextUpdate) userConfig = nil mountedDepots = {} sharedDepots = {} checkGuid = {} installScripts = {} userConfig = @AppState.UserConfig if @AppState.key?(:UserConfig) mountedDepots = @AppState.MountedDepots if @AppState.key?(:MountedDepots) sharedDepots = @AppState.SharedDepots if @AppState.key?(:sharedDepots) checkGuid = @AppState.CheckGuid if @AppState.key?(:CheckGuid) installScripts = @AppState.InstallScripts if @AppState.key?(:InstallScripts) @UserConfig = UserConfig.new(userConfig) @MountedDepots = MountedDepots.new(mountedDepots) @SharedDepots = SharedDepots.new(sharedDepots) @InstallScripts = InstallScripts.new(installScripts) end |
#to_hash ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/steam_codec/acf.rb', line 100 def to_hash result = {} self.class.scalarFields.each do |field| result[field.to_s] = self.send(field) end self.class.extendedFields.each do |field| result[field.to_s] = self.send(field) result[field.to_s] = result[field.to_s].to_hash if result[field.to_s] end result end |