Module: GameWeapon

Included in:
AbstractL4DWeapon, AlienSwarmWeapon, DoDSWeapon, L4DExplosive
Defined in:
lib/steam/community/game_weapon.rb

Overview

Super class for classes representing game weapons

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/steam/community/game_weapon.rb', line 9

def id
  @id
end

#killsObject (readonly)

Returns the value of attribute kills.



9
10
11
# File 'lib/steam/community/game_weapon.rb', line 9

def kills
  @kills
end

#shotsObject (readonly)

Returns the value of attribute shots.



9
10
11
# File 'lib/steam/community/game_weapon.rb', line 9

def shots
  @shots
end

Instance Method Details

#avg_shots_per_killObject

Returns the average number of shots needed for a kill with this weapon. Calculates the value if needed.



17
18
19
20
21
# File 'lib/steam/community/game_weapon.rb', line 17

def avg_shots_per_kill
  @avg_shots_per_kill = @shots.to_f / @kills if @avg_shots_per_kill.nil?

  @avg_shots_per_kill
end

#initialize(weapon_data) ⇒ Object



11
12
13
# File 'lib/steam/community/game_weapon.rb', line 11

def initialize(weapon_data)
  @kills     = weapon_data.elements['kills'].text.to_i
end