Last active
January 17, 2017 15:42
-
-
Save JuarezLustosa/8d6e555cd3f91712a2a2e0080b1929e3 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
Case | |
def set_pay_plan | |
progress = self.progress | |
case progress | |
when 0.01..0.74 | |
self.pay_plan = "s-20" | |
when 0.75..0.84 | |
self.pay_plan = "s-225" | |
when 0.85..1.05 | |
self.pay_plan = "s-25" | |
when 1.06..1.15 | |
self.pay_plan = "s-2625" | |
when 1.16..1.25 | |
self.pay_plan = "s-275" | |
when 1.26..1.35 | |
self.pay_plan = "s-2875" | |
when 1.36..1.49 | |
self.pay_plan = "s-30" | |
when 1.5..1.99 | |
self.pay_plan = "s-3125" | |
when 2.0..5.00 | |
self.pay_plan = "s-3375" | |
end | |
end | |
Refactor | |
def set_pay_plan | |
PAY_PLANS = [ | |
[0.01..0.74, "s-20"], | |
[0.75..0.84, "s-225"], | |
] | |
self.pay_plan = PAY_PLANS.find{ |range, name| range.include?(progress) }.last | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment