Class: CSSMap
- Inherits:
-
Object
- Object
- CSSMap
- Defined in:
- lib/steam/community/css/css_map.rb
Overview
Represents the stats for a Counter-Strike: Source map for a specific user
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Returns the name of this map.
-
#rounds_lost ⇒ Fixnum
readonly
Returns the number of rounds the player has lost on this map.
-
#rounds_played ⇒ Fixnum
readonly
Returns the number of rounds the player has played on this map.
-
#rounds_won ⇒ Fixnum
readonly
Returns the number of rounds the player has won on this map.
Instance Method Summary collapse
-
#favorite? ⇒ Boolean
Returns whether this map is the favorite map of this player.
-
#initialize(map_name, maps_data) ⇒ CSSMap
constructor
Creates a new instance of a Counter-Strike: Source class based on the given XML data.
-
#rounds_won_percentage ⇒ Float
Returns the percentage of rounds the player has won on this map.
Constructor Details
#initialize(map_name, maps_data) ⇒ CSSMap
Creates a new instance of a Counter-Strike: Source class based on the given XML data
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/steam/community/css/css_map.rb', line 36 def initialize(map_name, maps_data) @name = map_name @favorite = (maps_data['favorite'] == @name) @rounds_played = maps_data["#{@name}_rounds"].to_i @rounds_won = maps_data["#{@name}_wins"].to_i @rounds_lost = @rounds_played - @rounds_won @rounds_won_percentage = (@rounds_played > 0) ? @rounds_won.to_f / @rounds_played : 0 end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of this map
14 15 16 |
# File 'lib/steam/community/css/css_map.rb', line 14 def name @name end |
#rounds_lost ⇒ Fixnum (readonly)
Returns the number of rounds the player has lost on this map
19 20 21 |
# File 'lib/steam/community/css/css_map.rb', line 19 def rounds_lost @rounds_lost end |
#rounds_played ⇒ Fixnum (readonly)
Returns the number of rounds the player has played on this map
24 25 26 |
# File 'lib/steam/community/css/css_map.rb', line 24 def rounds_played @rounds_played end |
#rounds_won ⇒ Fixnum (readonly)
Returns the number of rounds the player has won on this map
29 30 31 |
# File 'lib/steam/community/css/css_map.rb', line 29 def rounds_won @rounds_won end |
Instance Method Details
#favorite? ⇒ Boolean
Returns whether this map is the favorite map of this player
50 51 52 |
# File 'lib/steam/community/css/css_map.rb', line 50 def favorite? @favorite end |
#rounds_won_percentage ⇒ Float
Returns the percentage of rounds the player has won on this map
57 58 59 |
# File 'lib/steam/community/css/css_map.rb', line 57 def rounds_won_percentage (@rounds_played > 0) ? @rounds_won.to_f / @rounds_played : 0 end |