Move self methods into self block

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

View File

@ -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|
@ -29,4 +30,5 @@ class GroupStageService
end end
matches matches
end end
end
end end