Module: GameWeapon
- Included in:
- AbstractL4DWeapon, AlienSwarmWeapon, DoDSWeapon, L4DExplosive
- Defined in:
- lib/steam/community/game_weapon.rb
Overview
A module implementing basic functionality for classes representing game weapons
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
Returns the unique identifier for this weapon.
-
#kills ⇒ Fixnum
readonly
Returns the number of kills achieved with this weapon.
-
#shots ⇒ Fixnum
readonly
Returns the number of shots fired with this weapon.
Instance Method Summary collapse
-
#avg_shots_per_kill ⇒ Float
Returns the average number of shots needed for a kill with this weapon.
-
#initialize(weapon_data) ⇒ Object
Creates a new game weapon instance with the data provided.
Instance Attribute Details
#id ⇒ String (readonly)
Returns the unique identifier for this weapon
20 21 22 |
# File 'lib/steam/community/game_weapon.rb', line 20 def id @id end |
#kills ⇒ Fixnum (readonly)
Returns the number of kills achieved with this weapon
15 16 17 |
# File 'lib/steam/community/game_weapon.rb', line 15 def kills @kills end |
#shots ⇒ Fixnum (readonly)
Returns the number of shots fired with this weapon
25 26 27 |
# File 'lib/steam/community/game_weapon.rb', line 25 def shots @shots end |
Instance Method Details
#avg_shots_per_kill ⇒ Float
Returns the average number of shots needed for a kill with this weapon
37 38 39 |
# File 'lib/steam/community/game_weapon.rb', line 37 def avg_shots_per_kill @shots.to_f / @kills end |
#initialize(weapon_data) ⇒ Object
Creates a new game weapon instance with the data provided
30 31 32 |
# File 'lib/steam/community/game_weapon.rb', line 30 def initialize(weapon_data) @kills = weapon_data['kills'].to_i end |