Class: CSSWeapon
- Inherits:
-
Object
- Object
- CSSWeapon
- Defined in:
- lib/steam/community/css/css_weapon.rb
Overview
CSSWeapon holds statistical information about weapons used by a player in Counter-Strike: Source.
Instance Attribute Summary collapse
-
#accuracy ⇒ Object
readonly
Returns the value of attribute accuracy.
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#kills ⇒ Object
readonly
Returns the value of attribute kills.
-
#ksratio ⇒ Object
readonly
Returns the value of attribute ksratio.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#shots ⇒ Object
readonly
Returns the value of attribute shots.
Instance Method Summary collapse
-
#favorite? ⇒ Boolean
Returns whether this weapon is the favorite weapon of this player.
-
#initialize(weapon_name, weapons_data) ⇒ CSSWeapon
constructor
Creates a new instance of CSSWeapon based on the assigned weapon name and XML data.
Constructor Details
#initialize(weapon_name, weapons_data) ⇒ CSSWeapon
Creates a new instance of CSSWeapon based on the assigned weapon name and XML data
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/steam/community/css/css_weapon.rb', line 14 def initialize(weapon_name, weapons_data) @name = weapon_name @favorite = (weapons_data.elements['favorite'].text == @name) @kills = weapons_data.elements["#{@name}_kills"].text.to_i if @name != 'grenade' && @name != 'knife' @hits = weapons_data.elements["#{@name}_hits"].text.to_i @shots = weapons_data.elements["#{@name}_shots"].text.to_i @accuracy = (@shots > 0) ? @hits.to_f / @shots : 0 @ksratio = (@shots > 0) ? @kills.to_f / @shots : 0 end end |
Instance Attribute Details
#accuracy ⇒ Object (readonly)
Returns the value of attribute accuracy.
10 11 12 |
# File 'lib/steam/community/css/css_weapon.rb', line 10 def accuracy @accuracy end |
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
10 11 12 |
# File 'lib/steam/community/css/css_weapon.rb', line 10 def hits @hits end |
#kills ⇒ Object (readonly)
Returns the value of attribute kills.
10 11 12 |
# File 'lib/steam/community/css/css_weapon.rb', line 10 def kills @kills end |
#ksratio ⇒ Object (readonly)
Returns the value of attribute ksratio.
10 11 12 |
# File 'lib/steam/community/css/css_weapon.rb', line 10 def ksratio @ksratio end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/steam/community/css/css_weapon.rb', line 10 def name @name end |
#shots ⇒ Object (readonly)
Returns the value of attribute shots.
10 11 12 |
# File 'lib/steam/community/css/css_weapon.rb', line 10 def shots @shots end |
Instance Method Details
#favorite? ⇒ Boolean
Returns whether this weapon is the favorite weapon of this player
29 30 31 |
# File 'lib/steam/community/css/css_weapon.rb', line 29 def favorite? @favorite end |