Class: DoDSStats

Inherits:
GameStats show all
Defined in:
lib/steam/community/dods/dods_stats.rb

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

Constructor Details

#initialize(steam_id) ⇒ DoDSStats

Creates a DoDSStats object by calling the super constructor with the game name “DoD:S”



13
14
15
# File 'lib/steam/community/dods/dods_stats.rb', line 13

def initialize(steam_id)
  super steam_id, 'DoD:S'
end

Instance Method Details

#class_statsObject

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.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/steam/community/dods/dods_stats.rb', line 19

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_statsObject

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.



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/steam/community/dods/dods_stats.rb', line 34

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