I want to refactor this ruby code
class UtilService
def summer_start
...
end
def summer_end
...
end
def calc(date, charge, quantity, winter_rate, winter_service_charge, summer_rate)
if date < summer_start || date > summer_end
chargeamt = quantity * winter_rate + winter_service_charge
else
chargeamt = quantity * summer_rate
end
chargeamt
end
end
Since charge isn't being used I know I can get rid of that but other than getting rid of that one parameter I can't think of what else I can actually do.
I was also thinking of breaking up 'calc' into different methods
class UtilService
def summer_start
end
def summer_end
end
def calc_summer_rate(date, quantity, summer_rate)
if date > summer_start || date < summer_end
chargeamt = quantity * summer_rate
end
chargeamt
end
def calc_winter_rate(date, quantity, winter_rate, winter_service_charge)
if date < summer_start || date > summer_end
chargeamt = quantity * winter_rate + winter_service_charge
end
chargeamt
end
end
But it doesn't seem like my refactoring makes much sense.