Class: L4DMap

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

Overview

This class holds statistical information about a map played by a player in Survival mode of Left4Dead

Author:

  • Sebastian Staudt

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_name, map_data) ⇒ L4DMap

Creates a new instance of a Left4Dead Survival map based on the given XML data

Parameters:

  • map_name (String)

    The name of this map

  • map_data (Hash<String, Object>)

    The XML data for this map



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/steam/community/l4d/l4d_map.rb', line 47

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

  case map_data['medal']
    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_timeFloat (readonly)

Returns the best survival time of this player on this map

Returns:

  • (Float)

    The best survival time of this player on this map



15
16
17
# File 'lib/steam/community/l4d/l4d_map.rb', line 15

def best_time
  @best_time
end

#idString (readonly)

Returns the ID of this map

Returns:

  • (String)

    The ID of this map



20
21
22
# File 'lib/steam/community/l4d/l4d_map.rb', line 20

def id
  @id
end

#medalFixnum (readonly)

Returns the highest medal this player has won on this map

Returns:

  • (Fixnum)

    The highest medal won by this player on this map



25
26
27
# File 'lib/steam/community/l4d/l4d_map.rb', line 25

def medal
  @medal
end

#nameString (readonly)

Returns the name of the map

Returns:

  • (String)

    The name of the map



30
31
32
# File 'lib/steam/community/l4d/l4d_map.rb', line 30

def name
  @name
end

#times_playedFixnum (readonly)

Returns the number of times this map has been played by this player

Returns:

  • (Fixnum)

    The number of times this map has been played



35
36
37
# File 'lib/steam/community/l4d/l4d_map.rb', line 35

def times_played
  @times_played
end