Class: DoDSStats

Inherits:
GameStats show all
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

Author:

  • Sebastian Staudt

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 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’‘

Parameters:

  • steam_id (String, Fixnum)

    The custom URL or 64bit Steam ID of the user



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

Returns:

  • (Hash<String, DoDSClass>)

    The class statistics for this user



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

Returns:

  • (Hash<String, DoDSWeapon>)

    The weapon statistics for this user



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