class Dota::API::Match
Public Instance Methods
cluster()
click to toggle source
# File lib/dota/api/match.rb, line 60 def cluster raw["cluster"] end
dire()
click to toggle source
# File lib/dota/api/match.rb, line 74 def dire @dire ||= Side.new(raw_side(:dire)) end
drafts()
click to toggle source
# File lib/dota/api/match.rb, line 64 def drafts @drafts ||= (raw["picks_bans"] || []).map do |raw_draft| Draft.new(raw_draft) end end
duration()
click to toggle source
# File lib/dota/api/match.rb, line 4 def duration raw["duration"] end
first_blood()
click to toggle source
# File lib/dota/api/match.rb, line 36 def first_blood raw["first_blood_time"] end
league_id()
click to toggle source
# File lib/dota/api/match.rb, line 8 def league_id raw["leagueid"] end
mode()
click to toggle source
# File lib/dota/api/match.rb, line 12 def mode MODES[raw["game_mode"]] end
mode_id()
click to toggle source
# File lib/dota/api/match.rb, line 16 def mode_id raw["game_mode"] end
negative_votes()
click to toggle source
# File lib/dota/api/match.rb, line 48 def negative_votes raw["negative_votes"] end
players_count()
click to toggle source
# File lib/dota/api/match.rb, line 56 def players_count raw["human_players"] end
positive_votes()
click to toggle source
# File lib/dota/api/match.rb, line 44 def positive_votes raw["positive_votes"] end
radiant()
click to toggle source
# File lib/dota/api/match.rb, line 70 def radiant @radiant ||= Side.new(raw_side(:radiant)) end
season()
click to toggle source
# File lib/dota/api/match.rb, line 52 def season raw["season"] end
sequence()
click to toggle source
# File lib/dota/api/match.rb, line 28 def sequence raw["match_seq_num"] end
starts_at()
click to toggle source
# File lib/dota/api/match.rb, line 32 def starts_at Time.at(raw["start_time"]) end
type()
click to toggle source
# File lib/dota/api/match.rb, line 20 def type TYPES[raw["lobby_type"]] end
type_id()
click to toggle source
# File lib/dota/api/match.rb, line 24 def type_id raw["lobby_type"] end
winner()
click to toggle source
# File lib/dota/api/match.rb, line 40 def winner raw["radiant_win"] ? :radiant : :dire end
Private Instance Methods
players_for_side(type)
click to toggle source
# File lib/dota/api/match.rb, line 87 def players_for_side(type) raw["players"].select do |player| case type when :radiant player["player_slot"] < Player::SLOT_GAP when :dire player["player_slot"] >= Player::SLOT_GAP end end end
raw_side(type)
click to toggle source
# File lib/dota/api/match.rb, line 80 def raw_side(type) pattern = /^#{type}_|_#{type}$/ raw_side = raw.select { |k, v| k.to_s.match(pattern) } raw_side = Hash[raw_side.map { |k, v| [k.sub(pattern, ""), v] }] raw_side.merge("players" => players_for_side(type)) end