Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Link a new or existing SteamId in GameStats

  • Loading branch information...
commit 63faa13d5f28752224d408a74a7661a59c8e0f9c 1 parent f90151d
@koraktor authored
Showing with 7 additions and 16 deletions.
  1. +7 −16 lib/steam/community/game_stats.rb
View
23 lib/steam/community/game_stats.rb
@@ -18,11 +18,6 @@ class GameStats
include XMLData
- # Returns the custom URL of the player these stats belong to
- #
- # @return [String] The custom URL of the player
- attr_reader :custom_url
-
# Returns the game these stats belong to
#
# @return [SteamGame] The game object
@@ -38,10 +33,10 @@ class GameStats
# @return [String] The privacy setting of the Steam ID
attr_reader :privacy_state
- # Returns the 64bit numeric SteamID of the player these stats belong to
+ # Returns the Steam ID of the player these stats belong to
#
- # @return [Fixnum] The 64bit numeric SteamID of the player
- attr_reader :steam_id64
+ # @return [SteamId] The Steam ID instance of the player
+ attr_reader :user
# Returns the base Steam Communtiy URL for the given player and game IDs
#
@@ -100,18 +95,14 @@ def self.create_game_stats(steam_id, game_name)
# Creates a `GameStats` object and fetches data from the Steam Community for
# the given user and game
#
- # @param [String, Fixnum] id The custom URL or the 64bit Steam ID of the
+ # @param [String, Fixnum] user_id The custom URL or the 64bit Steam ID of the
# user
# @param [String] game_id The application ID or friendly name of the game
# @raise [SteamCondenserError] if the stats cannot be fetched
- def initialize(id, game_id)
- if id.is_a? Numeric
- @steam_id64 = id
- else
- @custom_url = id.downcase
- end
+ def initialize(user_id, game_id)
+ @xml_data = parse "#{self.class.base_url(user_id, game_id)}?xml=all"
- @xml_data = parse "#{self.class.base_url(id, game_id)}?xml=all"
+ @user = SteamId.new user_id, false
error = @xml_data['error']
raise SteamCondenserError, error unless error.nil?
Please sign in to comment.
Something went wrong with that request. Please try again.