class SteamCodec::ValueArray

Public Class Methods

new(valueHash = {}) click to toggle source
# File lib/steam_codec/value_array.rb, line 4
def initialize(valueHash = {})
    load(valueHash)
end

Public Instance Methods

[](id) click to toggle source
# File lib/steam_codec/value_array.rb, line 16
def [](id)
    @ValueHash[id]
end
Also aliased as: get
[]=(id, file) click to toggle source
# File lib/steam_codec/value_array.rb, line 20
def []=(id, file)
    @ValueHash[id] = file
end
Also aliased as: set
add(file) click to toggle source
# File lib/steam_codec/value_array.rb, line 24
def add(file)
    id = @ValueHash.keys.max + 1
    @ValueHash[id] = file
    id
end
all()
Alias for: to_a
get(path = '', seperator = '.') click to toggle source
# File lib/steam_codec/value_array.rb, line 42
def get(path = '', seperator = '.')
    @ValueHash[path.to_i]
end
load(valueHash) click to toggle source
# File lib/steam_codec/value_array.rb, line 8
def load(valueHash)
    raise ArgumentError, "ValueHash must be instance of Hash" unless valueHash.is_a?(Hash)
    @ValueHash = {}
    valueHash.each do |id, file|
        @ValueHash[id.to_i] = file
    end
end
remove(id) click to toggle source
# File lib/steam_codec/value_array.rb, line 30
def remove(id)
    @ValueHash.delete(id)
end
set(id, file)
Alias for: []=
to_a() click to toggle source
# File lib/steam_codec/value_array.rb, line 34
def to_a
    check = []
    @ValueHash.sort_by { |key, value| key.to_s.to_i }.each do |array|
        check << array.last
    end
    check
end
Also aliased as: all
to_hash() click to toggle source
# File lib/steam_codec/value_array.rb, line 46
def to_hash
    @ValueHash
end