Class: L4DStats
- Includes:
- AbstractL4DStats
- Defined in:
- lib/steam/community/l4d/l4d_stats.rb
Constant Summary
Constants included from AbstractL4DStats
AbstractL4DStats::SPECIAL_INFECTED
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
-
#initialize(steam_id) ⇒ L4DStats
constructor
Creates a L4DStats object by calling the super constructor with the game name “l4d”.
-
#survival_stats ⇒ Object
Returns a Hash of Survival statistics for this user like revived teammates.
-
#weapon_stats ⇒ Object
Returns a Hash of L4DWeapon for this user containing all Left4Dead weapons.
Methods included from AbstractL4DStats
#favorites, #lifetime_stats, #teamplay_stats, #versus_stats
Methods inherited from GameStats
#achievements, #achievements_done, #achievements_percentage, #base_url, create_game_stats, #public?
Constructor Details
#initialize(steam_id) ⇒ L4DStats
Creates a L4DStats object by calling the super constructor with the game name “l4d”.
17 18 19 |
# File 'lib/steam/community/l4d/l4d_stats.rb', line 17 def initialize(steam_id) super steam_id, 'l4d' end |
Instance Method Details
#survival_stats ⇒ Object
Returns a Hash of Survival statistics for this user like revived teammates. If the Survival statistics haven’t been parsed already, parsing is done now.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/steam/community/l4d/l4d_stats.rb', line 23 def survival_stats return unless public? if @survival_stats.nil? super @survival_stats['maps'] = {} @xml_data.elements.each('stats/survival/maps/*') do |map_data| @survival_stats['maps'][map_data.name] = L4DMap.new(map_data) end end @survival_stats end |
#weapon_stats ⇒ Object
Returns a Hash of L4DWeapon for this user containing all Left4Dead weapons. If the weapons haven’t been parsed already, parsing is done now.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/steam/community/l4d/l4d_stats.rb', line 39 def weapon_stats return unless public? if @weapon_stats.nil? @weapon_stats = {} @xml_data.elements.each('stats/weapons/*') do |weapon_data| unless %w{molotov pipes}.include? weapon_data.name weapon = L4DWeapon.new(weapon_data) else weapon = L4DExplosive.new(weapon_data) end @weapon_stats[weapon_data.name] = weapon end end @weapon_stats end |