class Steam::Id::Base

Represents a SteamID holds the various parts of the Steam Id an internal 64bit datastructure

Attributes

struct[R]

Public Class Methods

new(struct = Struct.new) click to toggle source

Create a new Steam ID

# File lib/steam/id/base.rb, line 20
def initialize(struct = Struct.new)
  @struct = struct
end

Public Instance Methods

to_i() click to toggle source

Return the Steam Id in int format.

@return [Integer] the steam id in int format

# File lib/steam/id/base.rb, line 37
def to_i
  @struct.to_i
end
to_s(klass = Steam2Printer) click to toggle source

Return the Steam Id in string format. By default the Steam2 format is returned

@param klass [Printer] a steam id printer @return [String] the steam id in the desired format

# File lib/steam/id/base.rb, line 29
def to_s(klass = Steam2Printer)
  printer ||= klass.new(self)
  printer.print
end
valid?() click to toggle source

Returns true if the Steam id is valid

@return [Bool] true if valid, otherwise false

# File lib/steam/id/base.rb, line 44
def valid?
  valid_universe? && valid_account?
end

Private Instance Methods

valid_account?() click to toggle source

@api private

# File lib/steam/id/base.rb, line 51
def valid_account?
  return false if account_type <= EAccountType::INVALID ||
                  account_type >= EAccountType::MAX

  if account_type == EAccountType::INDIVIDUAL
    return false if account_id.zero?
  end

  true
end
valid_universe?() click to toggle source

@api private

# File lib/steam/id/base.rb, line 63
def valid_universe?
  return false if universe <= EUniverse::INVALID ||
                  universe >= EUniverse::MAX
  true
end