Class: DotkaM::Match
Instance Attribute Summary
Attributes inherited from Raw
#raw
Instance Method Summary
collapse
Methods inherited from Raw
#initialize
Constructor Details
This class inherits a constructor from DotkaM::Raw
Instance Method Details
#duration ⇒ Object
35
36
37
|
# File 'lib/dotka/match.rb', line 35
def duration
@raw["duration"].to_i
end
|
#game_mode ⇒ Object
47
48
49
|
# File 'lib/dotka/match.rb', line 47
def game_mode
GameMode.new Storage.new.get("game_modes", {"id" => @raw["game_mode"]})
end
|
#id ⇒ Object
13
14
15
|
# File 'lib/dotka/match.rb', line 13
def id
@raw["match_id"].to_i
end
|
#load_info(dotka) ⇒ Object
API limitation workaround.
56
57
58
59
60
61
62
|
# File 'lib/dotka/match.rb', line 56
def load_info dotka
raise "Expected an instance of Dotka." unless dotka.is_a? Dotka
@raw = dotka.match(self.id).raw
end
|
#lobby ⇒ Object
43
44
45
|
# File 'lib/dotka/match.rb', line 43
def lobby
Lobby.new Storage.new.get("lobbies", {"id" => @raw["lobby_type"]})
end
|
#player(account_id) ⇒ Object
27
28
29
|
# File 'lib/dotka/match.rb', line 27
def player account_id
players.select { |player| player.account_id == account_id.to_i }.first
end
|
#players ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/dotka/match.rb', line 17
def players
players = Array.new
@raw["players"].each { |player| players.push Player.new(player) }
players
end
|
#region ⇒ Object
51
52
53
|
# File 'lib/dotka/match.rb', line 51
def region
Region.new Storage.new.get("regions", {"id" => @raw["cluster"]})
end
|
#start_time ⇒ Object
39
40
41
|
# File 'lib/dotka/match.rb', line 39
def start_time
@raw["start_time"].to_i
end
|
#winner ⇒ Object
31
32
33
|
# File 'lib/dotka/match.rb', line 31
def winner
(!! @raw["radiant_win"]) ? "radiant" : "dire"
end
|