Class: TF2Stats
- Defined in:
- lib/steam/community/tf2/tf2_stats.rb
Overview
The TF2Stats class represents the game statistics for a single user in Team Fortress 2
Instance Attribute Summary collapse
-
#accumulated_points ⇒ Object
readonly
Returns the value of attribute accumulated_points.
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 ⇒ Object
Returns a Hash of TF2Class for this user containing all Team Fortress 2 classes.
-
#initialize(steam_id) ⇒ TF2Stats
constructor
Creates a TF2Stats object by calling the super constructor with the game name “tf2”.
-
#inventory ⇒ Object
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, #public?
Constructor Details
#initialize(steam_id) ⇒ TF2Stats
Creates a TF2Stats object by calling the super constructor with the game name “tf2”
18 19 20 21 22 23 24 |
# File 'lib/steam/community/tf2/tf2_stats.rb', line 18 def initialize(steam_id) super steam_id, 'tf2' if public? @accumulated_points = @xml_data.elements['stats/accumulatedPoints'].text.to_i end end |
Instance Attribute Details
#accumulated_points ⇒ Object (readonly)
Returns the value of attribute accumulated_points.
14 15 16 |
# File 'lib/steam/community/tf2/tf2_stats.rb', line 14 def accumulated_points @accumulated_points end |
Instance Method Details
#class_stats ⇒ Object
Returns a Hash of TF2Class for this user containing all Team Fortress 2 classes. If the classes haven’t been parsed already, parsing is done now.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/steam/community/tf2/tf2_stats.rb', line 28 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 ⇒ Object
Returns the current Team Fortress 2 inventory (a.k.a. backpack) of this player
43 44 45 46 |
# File 'lib/steam/community/tf2/tf2_stats.rb', line 43 def inventory @inventory = TF2Inventory.new(steam_id64) if @inventory.nil? @inventory end |