struct Steam::ID::Mask

Overview

A Mask is used as basic wrapper around UInt64 for performing binary operations, specifically for composing the binary format of a Steam ID. Its namespace includes constants for each component of an ID that can be used to decode a UInt64 with #extract_from.

Masks

LowestBit - The first bit of the number. It is used only in encoding a 64 bit ID into certain string formats.

0b0000000000000000000000000000000000000000000000000000000000000001

AccountID - The canonical ID of the account encoded in the ID

0b0000000000000000000000000000000011111111111111111111111111111110

Instance - The instance of the account

0b0000000000001111111111111111111100000000000000000000000000000000

AccountType - The type of this account. Abstracted as ID::AccountType

0b0000000011110000000000000000000000000000000000000000000000000000

Universe - The universe this account belongs to. Abstracted as ID::Universe

0b1111111100000000000000000000000000000000000000000000000000000000

Example

example

(Taken from SteamID docs)

binary = 0b00000001_0001_00000000000000000001_0000011111100010010111110100001_1
#                 A    B                    C                               D E
# A: Universe
Steam::ID::Mask::Universe.extract_from(binary) # => 1
# B: AccountType
Steam::ID::Mask::AccountType.extract_from(binary) # => 1
# C: Instance
Steam::ID::Mask::Instance.extract_from(binary) # => 1
# D: AccountID
Steam::ID::Mask::AccountID.extract_from(binary) # => 66138017
# E: LowestBit
Steam::ID::Mask::LowestBit.extract_from(binary) # => 1

Defined in:

mask.cr

Constant Summary

AccountID = Mask.new(31, LowestBit)
AccountType = Mask.new(4, Instance)
Instance = Mask.new(20, AccountID)
LowestBit = Mask.new(1, 0)
Universe = Mask.new(8, AccountType)

Constructors

Instance Method Summary

Constructor Detail

def self.new(size : UInt64, offset : UInt64 = 0) #

[View source]
def self.new(size : UInt64, after : Mask) #

[View source]

Instance Method Detail

def extract_from(value : UInt64) #

[View source]
def mask : UInt64 #

[View source]
def offset(value : UInt64) #

[View source]
def offset : UInt64 #

[View source]
def size : UInt64 #

[View source]