Skip to content

Commit

Permalink
Resolve SteamID vanity URLs on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
koraktor committed Jul 27, 2015
1 parent 5d70692 commit 0a36904
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/steam-condenser/community/steam_id.rb
Expand Up @@ -103,11 +103,6 @@ class SteamId
# @see #online?
attr_reader :state_message

# Returns this user's 64bit SteamID
#
# @return [Fixnum] This user's 64bit SteamID
attr_reader :steam_id64

# Returns the Steam rating calculated over the last two weeks' activity
#
# @return [Float] The Steam rating of this user
Expand Down Expand Up @@ -318,7 +313,7 @@ def fetch
# @see #friends
# @see #initialize
def fetch_friends
params = { :relationship => 'friend', :steamid => @steam_id64 }
params = { :relationship => 'friend', :steamid => steam_id64 }

friends_data = WebApi.json 'ISteamUser', 'GetFriendList', 1, params
@friends = friends_data[:friendslist][:friends].map do |friend|
Expand All @@ -337,7 +332,7 @@ def fetch_games
params = {
:include_appinfo => 1,
:include_played_free_games => 1,
:steamId => @steam_id64
:steamId => steam_id64
}
games_data = WebApi.json 'IPlayerService', 'GetOwnedGames', 1, params
@games = {}
Expand Down Expand Up @@ -481,6 +476,16 @@ def recent_playtime(app_id)
@recent_playtimes[app_id]
end

# Returns this user's 64bit SteamID
#
# If the SteamID is not known yet it is resolved from the vanity URL.
#
# @return [Fixnum] This user's 64bit SteamID
# @see .resolve_vanity_url
def steam_id64
@steam_id64 || self.class.resolve_vanity_url(@custom_url)
end

# Returns the current Steam level of this user
#
# If the Steam level hasn't been updated yet, this is done now.
Expand Down

0 comments on commit 0a36904

Please sign in to comment.