Class: CSSMap

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#nameObject (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_lostObject (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_playedObject (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_wonObject (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_percentageObject (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

Returns:

  • (Boolean)


27
28
29
# File 'lib/steam/community/css/css_map.rb', line 27

def favorite?
  @favorite
end