Class: DotkaM::Match

Inherits:
Raw
  • Object
show all
Defined in:
lib/dotka/match.rb

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

#durationObject



35
36
37
# File 'lib/dotka/match.rb', line 35

def duration
  @raw["duration"].to_i
end

#game_modeObject



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

#idObject



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

#lobbyObject



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 
  players.select { |player| player. == .to_i }.first
end

#playersObject



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

#regionObject



51
52
53
# File 'lib/dotka/match.rb', line 51

def region
  Region.new Storage.new.get("regions", {"id" => @raw["cluster"]})
end

#start_timeObject



39
40
41
# File 'lib/dotka/match.rb', line 39

def start_time
  @raw["start_time"].to_i
end

#winnerObject



31
32
33
# File 'lib/dotka/match.rb', line 31

def winner
  (!! @raw["radiant_win"]) ? "radiant" : "dire"
end