Class: Smite::FullMatch
Instance Attribute Summary collapse
Attributes inherited from Object
#data
Instance Method Summary
collapse
Methods inherited from Object
#attributes, #method_missing
Constructor Details
#initialize(data) ⇒ FullMatch
Returns a new instance of FullMatch.
5
6
7
8
9
10
|
# File 'lib/smite/full_match.rb', line 5
def initialize(data)
data = { 'competitors' => data.map { |k, v| Smite::Competitor.new(k) } }
super
@queue = competitors[0].queue
@match = competitors[0].match
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Smite::Object
Instance Attribute Details
Returns the value of attribute match.
3
4
5
|
# File 'lib/smite/full_match.rb', line 3
def match
@match
end
|
Returns the value of attribute queue.
3
4
5
|
# File 'lib/smite/full_match.rb', line 3
def queue
@queue
end
|
Instance Method Details
53
54
55
|
# File 'lib/smite/full_match.rb', line 53
def inspect
"#<Smite::FullMatch #{match} #{queue}>"
end
|
16
17
18
|
# File 'lib/smite/full_match.rb', line 16
def parties
competitors.group_by(&:party_id)
end
|
20
21
22
|
# File 'lib/smite/full_match.rb', line 20
def players
competitors
end
|
#ranked? ⇒ Boolean
28
29
30
|
# File 'lib/smite/full_match.rb', line 28
def ranked?
queue =~ /Ranked/
end
|
24
25
26
|
# File 'lib/smite/full_match.rb', line 24
def size
competitors.count
end
|
32
33
34
|
# File 'lib/smite/full_match.rb', line 32
def size_str
"#{size/2} v #{size/2}"
end
|
36
37
38
|
# File 'lib/smite/full_match.rb', line 36
def team1
competitors[0...size/2]
end
|
40
41
42
|
# File 'lib/smite/full_match.rb', line 40
def team2
competitors[size/2..-1]
end
|
12
13
14
|
# File 'lib/smite/full_match.rb', line 12
def teams
{ team1: team1, team2: team2 }
end
|
#winning_team ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/smite/full_match.rb', line 44
def winning_team
return @winner unless @winner.nil?
@winner = teams.find do |team, competitors|
competitors.all? { |competitor| competitor.winner? }
end
@winner = @winner[0]
end
|