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

Author:

  • Sebastian Staudt

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idString (readonly)

Returns the unique identifier for this weapon

Returns:

  • (String)

    The identifier of this weapon



20
21
22
# File 'lib/steam/community/game_weapon.rb', line 20

def id
  @id
end

#killsFixnum (readonly)

Returns the number of kills achieved with this weapon

Returns:

  • (Fixnum)

    The number of kills achieved



15
16
17
# File 'lib/steam/community/game_weapon.rb', line 15

def kills
  @kills
end

#shotsFixnum (readonly)

Returns the number of shots fired with this weapon

Returns:

  • (Fixnum)

    The number of shots fired



25
26
27
# File 'lib/steam/community/game_weapon.rb', line 25

def shots
  @shots
end

Instance Method Details

#avg_shots_per_killFloat

Returns the average number of shots needed for a kill with this weapon

Returns:

  • (Float)

    The average number of shots needed for a kill



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

Parameters:

  • weapon_data (Hash<String, Object>)

    The data representing this weapon



30
31
32
# File 'lib/steam/community/game_weapon.rb', line 30

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