Class: L4DStats

Inherits:
GameStats show all
Includes:
AbstractL4DStats
Defined in:
lib/steam/community/l4d/l4d_stats.rb

Overview

This class represents the game statistics for a single user in Left4Dead

Author:

  • Sebastian Staudt

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

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, #leaderboard, #leaderboards, #public?

Constructor Details

#initialize(steam_id) ⇒ L4DStats

Creates a ‘L4DStats` object by calling the super constructor with the game name `’l4d’‘

Parameters:

  • steam_id (String)

    The custom URL or 64bit Steam ID of the user



22
23
24
# File 'lib/steam/community/l4d/l4d_stats.rb', line 22

def initialize(steam_id)
  super steam_id, 'l4d'
end

Instance Method Details

#survival_statsHash<String, 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.

Returns:

  • (Hash<String, Object>)

    The stats for the Survival mode



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/steam/community/l4d/l4d_stats.rb', line 32

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_statsHash<String, 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.

Returns:

  • (Hash<String, Object>)

    The weapon statistics



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/steam/community/l4d/l4d_stats.rb', line 52

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