Class: L4DMap

Inherits:
Object
  • Object
show all
Defined in:
lib/steam/community/l4d/l4d_map.rb

Overview

L4DMap holds statistical information about maps played by a player in Survival mode of Left4Dead.

Direct Known Subclasses

L4D2Map

Constant Summary collapse

GOLD =
1
SILVER =
2
BRONZE =
3
NONE =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map_data) ⇒ L4DMap

Creates a new instance of L4DMap based on the assigned XML data



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/steam/community/l4d/l4d_map.rb', line 18

def initialize(map_data)
  @best_time    = map_data.elements['besttimeseconds'].text.to_f
  @id           = map_data.name
  @name         = map_data.elements['name'].text
  @times_played = map_data.elements['timesplayed'].text.to_i

  case map_data.elements['medal'].text
    when 'gold'
      @medal = L4DMap::GOLD
    when 'silver'
      @medal = L4DMap::SILVER
    when 'bronze'
      @medal = L4DMap::BRONZE
    else
      @medal = L4DMap::NONE
  end
end

Instance Attribute Details

#best_timeObject (readonly)

Returns the value of attribute best_time.



10
11
12
# File 'lib/steam/community/l4d/l4d_map.rb', line 10

def best_time
  @best_time
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/steam/community/l4d/l4d_map.rb', line 10

def id
  @id
end

#medalObject (readonly)

Returns the value of attribute medal.



10
11
12
# File 'lib/steam/community/l4d/l4d_map.rb', line 10

def medal
  @medal
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/steam/community/l4d/l4d_map.rb', line 10

def name
  @name
end

#times_playedObject (readonly)

Returns the value of attribute times_played.



10
11
12
# File 'lib/steam/community/l4d/l4d_map.rb', line 10

def times_played
  @times_played
end