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
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#kills ⇒ Object
readonly
Returns the value of attribute kills.
-
#shots ⇒ Object
readonly
Returns the value of attribute shots.
Instance Method Summary collapse
-
#avg_shots_per_kill ⇒ Object
Returns the average number of shots needed for a kill with this weapon.
- #initialize(weapon_data) ⇒ Object
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/steam/community/game_weapon.rb', line 9 def id @id end |
#kills ⇒ Object (readonly)
Returns the value of attribute kills.
9 10 11 |
# File 'lib/steam/community/game_weapon.rb', line 9 def kills @kills end |
#shots ⇒ Object (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_kill ⇒ Object
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 |