class SteamCodec::ACF

Attributes

BuildID[RW]
BytesDownloaded[RW]
BytesToDownload[RW]
CheckGuid[R]
FullValidateOnNextUpdate[RW]
InstallDir[RW]
InstallScripts[R]
LastOwner[RW]
LastUpdated[RW]
MountedDepots[R]
SharedDepots[R]
SizeOnDisk[RW]
StateFlags[RW]
Universe[RW]
UpdateResult[RW]
UserConfig[R]

Public Class Methods

extendedFields() click to toggle source
# File lib/steam_codec/acf.rb, line 30
def self.extendedFields
    return [:UserConfig, :MountedDepots, :SharedDepots, :CheckGuid, :InstallScripts]
end
load(data) click to toggle source
# 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) click to toggle source
# 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
new(appState = nil) click to toggle source
# File lib/steam_codec/acf.rb, line 46
def initialize(appState = nil)
    load(appState || KeyValues.new)
end
scalarFields() click to toggle source
# 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

Public Instance Methods

get(path = '', seperator = '.') click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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