Move self methods into self block

This commit is contained in:
Daniel Schädler 2019-05-10 11:34:01 +02:00
parent 6f4c7d3edd
commit a4ea0cf979
1 changed files with 26 additions and 24 deletions

View File

@ -1,7 +1,8 @@
# frozen_string_literal: true
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 an error if the average group size is not a whole number
@ -11,11 +12,11 @@ class GroupStageService
Stage.new level: -1, groups: groups
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)
end
def self.generate_all_matches_between(teams)
def generate_all_matches_between(teams)
matches = []
teams.combination(2).to_a # = matchups
.each_with_index do |matchup, i|
@ -29,4 +30,5 @@ class GroupStageService
end
matches
end
end
end