Class: Playoffs::Tournament
- Inherits:
-
Object
- Object
- Playoffs::Tournament
show all
- Extended by:
- T::Sig
- Includes:
- Bracketable, Roundable
- Defined in:
- lib/playoffs/tournament.rb,
lib/playoffs/tournament/roundable.rb
Overview
Models the construction and lifecycle of a set of series in the configured order leading to completion.
Defined Under Namespace
Modules: Roundable
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Roundable
#current_round, #print_rounds
#print_bracket
Constructor Details
#initialize(championship) ⇒ Tournament
Returns a new instance of Tournament.
22
23
24
25
|
# File 'lib/playoffs/tournament.rb', line 22
def initialize(championship)
@championship = T.let(championship, Series)
@rounds = T.let(rounds_from_series(championship), T::Array[Round])
end
|
Instance Attribute Details
#championship ⇒ Object
Returns the value of attribute championship.
16
17
18
|
# File 'lib/playoffs/tournament.rb', line 16
def championship
@championship
end
|
#rounds ⇒ Object
Returns the value of attribute rounds.
19
20
21
|
# File 'lib/playoffs/tournament.rb', line 19
def rounds
@rounds
end
|
Instance Method Details
#not_over ⇒ Object
52
53
54
|
# File 'lib/playoffs/tournament.rb', line 52
def not_over
rounds.select(&:not_over?)
end
|
#not_over? ⇒ Boolean
47
48
49
|
# File 'lib/playoffs/tournament.rb', line 47
def not_over?
!up_next.nil?
end
|
#over? ⇒ Boolean
42
43
44
|
# File 'lib/playoffs/tournament.rb', line 42
def over?
!not_over?
end
|
#to_s ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/playoffs/tournament.rb', line 28
def to_s
[
print_bracket,
'',
print_rounds
].join("\n")
end
|
#up_next ⇒ Object
37
38
39
|
# File 'lib/playoffs/tournament.rb', line 37
def up_next
current_round&.up_next
end
|
#winner ⇒ Object
57
58
59
|
# File 'lib/playoffs/tournament.rb', line 57
def winner
championship.winner
end
|