Class: CSSMap
- Inherits:
-
Object
- Object
- CSSMap
- Defined in:
- lib/steam/community/css/css_map.rb
Overview
CSSMap holds statistical information about maps played by a player in Counter-Strike: Source.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rounds_lost ⇒ Object
readonly
Returns the value of attribute rounds_lost.
-
#rounds_played ⇒ Object
readonly
Returns the value of attribute rounds_played.
-
#rounds_won ⇒ Object
readonly
Returns the value of attribute rounds_won.
-
#rounds_won_percentage ⇒ Object
readonly
Returns the value of attribute rounds_won_percentage.
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 CSSMap based on the assigned map name and XML data.
Constructor Details
#initialize(map_name, maps_data) ⇒ CSSMap
Creates a new instance of CSSMap based on the assigned map name and XML data
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/steam/community/css/css_map.rb', line 15 def initialize(map_name, maps_data) @name = map_name @favorite = (maps_data.elements['favorite'].text == @name) @rounds_played = maps_data.elements["#{@name}_rounds"].text.to_i @rounds_won = maps_data.elements["#{@name}_wins"].text.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 ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/steam/community/css/css_map.rb', line 10 def name @name end |
#rounds_lost ⇒ Object (readonly)
Returns the value of attribute rounds_lost.
10 11 12 |
# File 'lib/steam/community/css/css_map.rb', line 10 def rounds_lost @rounds_lost end |
#rounds_played ⇒ Object (readonly)
Returns the value of attribute rounds_played.
10 11 12 |
# File 'lib/steam/community/css/css_map.rb', line 10 def rounds_played @rounds_played end |
#rounds_won ⇒ Object (readonly)
Returns the value of attribute rounds_won.
10 11 12 |
# File 'lib/steam/community/css/css_map.rb', line 10 def rounds_won @rounds_won end |
#rounds_won_percentage ⇒ Object (readonly)
Returns the value of attribute rounds_won_percentage.
10 11 12 |
# File 'lib/steam/community/css/css_map.rb', line 10 def rounds_won_percentage @rounds_won_percentage end |
Instance Method Details
#favorite? ⇒ Boolean
Returns whether this map is the favorite map of this player
27 28 29 |
# File 'lib/steam/community/css/css_map.rb', line 27 def favorite? @favorite end |