Class: DoDSStats
- Defined in:
- lib/steam/community/dods/dods_stats.rb
Overview
The is class represents the game statistics for a single user in Day of Defeat: Source
Instance Attribute Summary
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, DoDSClass>
Returns a hash of ‘DoDSClass` for this user containing all DoD:S classes.
-
#initialize(steam_id) ⇒ DoDSStats
constructor
Creates a ‘DoDSStats` instance by calling the super constructor with the game name `’DoD:S’‘.
-
#weapon_stats ⇒ Hash<String, DoDSWeapon>
Returns a Hash of ‘DoDSWeapon` for this user containing all DoD:S weapons.
Methods inherited from GameStats
#achievements, #achievements_done, #achievements_percentage, #base_url, create_game_stats, #leaderboard, #leaderboards, #public?
Constructor Details
#initialize(steam_id) ⇒ DoDSStats
Creates a ‘DoDSStats` instance by calling the super constructor with the game name `’DoD:S’‘
20 21 22 |
# File 'lib/steam/community/dods/dods_stats.rb', line 20 def initialize(steam_id) super steam_id, 'DoD:S' end |
Instance Method Details
#class_stats ⇒ Hash<String, DoDSClass>
Returns a hash of ‘DoDSClass` for this user containing all DoD:S classes.
If the classes haven’t been parsed already, parsing is done now.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/steam/community/dods/dods_stats.rb', line 29 def class_stats return unless public? if @class_stats.nil? @class_stats = {} @xml_data.elements.each('stats/classes/class') do |class_data| @class_stats[class_data.attributes['key']] = DoDSClass.new class_data end end @class_stats end |
#weapon_stats ⇒ Hash<String, DoDSWeapon>
Returns a Hash of ‘DoDSWeapon` for this user containing all DoD:S weapons.
If the weapons haven’t been parsed already, parsing is done now.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/steam/community/dods/dods_stats.rb', line 47 def weapon_stats return unless public? if @weapon_stats.nil? @weapon_stats = {} @xml_data.elements.each('stats/weapons/weapon') do |weapon_data| @weapon_stats[weapon_data.attributes['key']] = DoDSWeapon.new(weapon_data) end end @weapon_stats end |