Class: SteamID::SteamID
- Inherits:
-
Object
- Object
- SteamID::SteamID
- Defined in:
- lib/steam-id/steam_id.rb
Overview
Class representing a single Steam ID - that is, one logical account
Constant Summary collapse
- ID_64_OFFSET =
Offset between ID 64 and account ID.
76561197960265728
- PROFILE_BASE_URL =
Base URL for Steam community profiles based on ID64 / ID3.
"https://steamcommunity.com/profiles"
Instance Attribute Summary collapse
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
Instance Method Summary collapse
-
#id ⇒ String
Classical Steam ID (eg STEAM_0:.…).
-
#id_3 ⇒ String
Steam ID 3 (eg [U:1:…]).
-
#id_64 ⇒ Integer
Steam ID 64 / Steam profile ID (eg 765…).
-
#initialize(account_id) ⇒ SteamID
constructor
Create new SteamID.
-
#profile_url ⇒ String
URL to player’s profile on Steam community.
Constructor Details
#initialize(account_id) ⇒ SteamID
Create new SteamID
15 16 17 |
# File 'lib/steam-id/steam_id.rb', line 15 def initialize(account_id) @account_id = account_id end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
11 12 13 |
# File 'lib/steam-id/steam_id.rb', line 11 def account_id @account_id end |
Instance Method Details
#id ⇒ String
Returns Classical Steam ID (eg STEAM_0:.…).
20 21 22 23 24 25 |
# File 'lib/steam-id/steam_id.rb', line 20 def id offset = @account_id / 2 index = @account_id - 2 * offset "STEAM_0:#{ index }:#{ offset }" end |
#id_3 ⇒ String
Returns Steam ID 3 (eg [U:1:…]).
33 34 35 |
# File 'lib/steam-id/steam_id.rb', line 33 def id_3 "[U:1:#{ @account_id }]" end |
#id_64 ⇒ Integer
Returns Steam ID 64 / Steam profile ID (eg 765…).
28 29 30 |
# File 'lib/steam-id/steam_id.rb', line 28 def id_64 @account_id + ID_64_OFFSET end |
#profile_url ⇒ String
Returns URL to player’s profile on Steam community.
38 39 40 |
# File 'lib/steam-id/steam_id.rb', line 38 def profile_url "#{ PROFILE_BASE_URL }/#{ id_64 }" end |