Use methods instead of attributes

because each attribute is only used once and updating a Stage should
reflect those changes
This commit is contained in:
Thor77 2019-05-14 22:26:57 +02:00
parent d6a691fe5a
commit 37b63cace2
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
1 changed files with 11 additions and 7 deletions

View File

@ -5,15 +5,19 @@ class StatisticsService
raise 'Unsupported stage type' if stage.nil? || stage.groups.empty?
@stage = stage
@group_scores = sort_group_scores(@stage.groups, :group_points)
@most_dominant_score = sort_group_scores(@stage.groups, :scored_points).first
@least_dominant_score = sort_group_scores(@stage.groups, :received_points).first
end
attr_reader :group_scores
attr_reader :most_dominant_score
attr_reader :least_dominant_score
def group_scores
sort_group_scores(@stage.groups, :group_points)
end
def most_dominant_score
sort_group_scores(@stage.groups, :scored_points).first
end
def least_dominant_score
sort_group_scores(@stage.groups, :received_points).first
end
private