Class: TF2Stats
- Defined in:
- lib/steam/community/tf2/tf2_stats.rb
Overview
This class represents the game statistics for a single user in Team Fortress 2
Instance Attribute Summary collapse
-
#accumulated_points ⇒ Fixnum
readonly
Returns the total points this player has achieved in his career.
Attributes inherited from GameStats
#app_id, #custom_url, #game_friendly_name, #game_name, #hours_played, #privacy_state, #steam_id64
Instance Method Summary collapse
-
#class_stats ⇒ Hash<String, TF2Class>
Returns the statistics for all Team Fortress 2 classes for this user.
-
#initialize(steam_id, beta = false) ⇒ TF2Stats
constructor
Creates a ‘TF2Stats` instance by calling the super constructor with the game name `’tf2’‘.
-
#inventory ⇒ TF2Inventory
Returns the current Team Fortress 2 inventory (a.k.a. backpack) of this player.
Methods inherited from GameStats
#achievements, #achievements_done, #achievements_percentage, #base_url, create_game_stats, #leaderboard, #leaderboards, #public?
Constructor Details
#initialize(steam_id, beta = false) ⇒ TF2Stats
Creates a ‘TF2Stats` instance by calling the super constructor with the game name `’tf2’‘
28 29 30 31 32 33 34 |
# File 'lib/steam/community/tf2/tf2_stats.rb', line 28 def initialize(steam_id, beta = false) super steam_id, (beta ? '520' : 'tf2') if public? && !@xml_data.elements['stats/accumulatedPoints'].nil? @accumulated_points = @xml_data.elements['stats/accumulatedPoints'].text.to_i end end |
Instance Attribute Details
#accumulated_points ⇒ Fixnum (readonly)
Returns the total points this player has achieved in his career
20 21 22 |
# File 'lib/steam/community/tf2/tf2_stats.rb', line 20 def accumulated_points @accumulated_points end |
Instance Method Details
#class_stats ⇒ Hash<String, TF2Class>
Returns the statistics for all Team Fortress 2 classes for this user
If the classes haven’t been parsed already, parsing is done now.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/steam/community/tf2/tf2_stats.rb', line 42 def class_stats return unless public? if @class_stats.nil? @class_stats = Hash.new @xml_data.elements.each('stats/classData') do |class_data| @class_stats[class_data.elements['className'].text] = TF2ClassFactory.tf2_class(class_data) end end @class_stats end |
#inventory ⇒ TF2Inventory
Returns the current Team Fortress 2 inventory (a.k.a. backpack) of this player
59 60 61 62 63 64 65 66 |
# File 'lib/steam/community/tf2/tf2_stats.rb', line 59 def inventory if @inventory.nil? inventory_class = (game_friendly_name == 'tf2') ? TF2Inventory : TF2BetaInventory @inventory = inventory_class.new(steam_id64) if @inventory.nil? end @inventory end |