Move self methods into self block
This commit is contained in:
parent
f51936f8e7
commit
08b190e65b
|
|
@ -1,7 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class GroupStageService
|
class GroupStageService
|
||||||
def self.generate_group_stage(groups)
|
class << self
|
||||||
|
def generate_group_stage(groups)
|
||||||
raise 'Cannot generate group stage without groups' if groups.length.zero?
|
raise 'Cannot generate group stage without groups' if groups.length.zero?
|
||||||
|
|
||||||
# raise an error if the average group size is not a whole number
|
# raise an error if the average group size is not a whole number
|
||||||
|
|
@ -11,11 +12,11 @@ class GroupStageService
|
||||||
Stage.new level: -1, groups: groups
|
Stage.new level: -1, groups: groups
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_group_object_from(team_array)
|
def get_group_object_from(team_array)
|
||||||
Group.new matches: generate_all_matches_between(team_array)
|
Group.new matches: generate_all_matches_between(team_array)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.generate_all_matches_between(teams)
|
def generate_all_matches_between(teams)
|
||||||
matches = []
|
matches = []
|
||||||
teams.combination(2).to_a # = matchups
|
teams.combination(2).to_a # = matchups
|
||||||
.each_with_index do |matchup, i|
|
.each_with_index do |matchup, i|
|
||||||
|
|
@ -30,3 +31,4 @@ class GroupStageService
|
||||||
matches
|
matches
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue