Last active
August 11, 2020 03:38
-
-
Save vtno/dbea8d331a0e01ecf2b9255ba03ff6b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QualityCalculator | |
def self.calculate_for_normal_award(award) | |
# normal award logic here | |
# which would update the quality of the award passed in | |
return award | |
end | |
def self.calculate_for_blue_first_award(award) | |
# blue first award logic here | |
# which would update the quality of the award passed in | |
return award | |
end | |
def self.calculate_for_blue_distinction_award(award) | |
# blue distinction award logic here | |
# which would update the quality of the award passed in | |
return award | |
end | |
def self.calculate(award) | |
return QualityCalculator.calculate_for_blue_distinction_award(award) if award.name == 'Blue Distinction' | |
return QualityCalculator.calculate_for_blue_first_award(award) if award.name == 'Blue First' | |
QualityCalculator.calculate_for_normal_award(award) | |
end | |
end | |
# then you can use it in update_quality method | |
def update_quality(awards) | |
awards.each { |award| QualityCalculator.calculate(award) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment