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

#game, #hours_played, #privacy_state, #user

Instance Method Summary collapse

Methods inherited from GameStats

#achievements, #achievements_done, #achievements_percentage, base_url, #base_url, create_game_stats, #public?

Methods included from XMLData

#parse

Constructor Details

#initialize(steam_id, fetch = true, bypass_cache = false) ⇒ 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

  • fetch (Boolean)

    if ‘true` the object’s data is fetched after creation

  • bypass_cache (Boolean)

    if ‘true` the object’s data is fetched again even if it has been cached already



22
23
24
# File 'lib/steam/community/dods/dods_stats.rb', line 22

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



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/steam/community/dods/dods_stats.rb', line 31

def class_stats
  return unless public?

  if @class_stats.nil?
    @class_stats = {}
    @xml_data['stats']['classes']['class'].each do |class_data|
      @class_stats[class_data['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



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/steam/community/dods/dods_stats.rb', line 49

def weapon_stats
  return unless public?

  if @weapon_stats.nil?
    @weapon_stats = {}
    @xml_data['stats']['weapons']['weapon'].each do |weapon_data|
      @weapon_stats[weapon_data['key']] = DoDSWeapon.new weapon_data
    end
  end

  @weapon_stats
end