Class: SteamID::SteamID

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(account_id) ⇒ SteamID

Create new SteamID

Parameters:

  • account_id (Integer)

    Numeric account ID.



15
16
17
# File 'lib/steam-id/steam_id.rb', line 15

def initialize()
  @account_id = 
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



11
12
13
# File 'lib/steam-id/steam_id.rb', line 11

def 
  @account_id
end

Instance Method Details

#idString

Returns Classical Steam ID (eg STEAM_0:.…).

Returns:

  • (String)

    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_3String

Returns Steam ID 3 (eg [U:1:…]).

Returns:

  • (String)

    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_64Integer

Returns Steam ID 64 / Steam profile ID (eg 765…).

Returns:

  • (Integer)

    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_urlString

Returns URL to player’s profile on Steam community.

Returns:

  • (String)

    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