If we create a new method called days_left_in_current_level, what would we need to put in there so that we can count how many days are left in the current_level?
habit.rb
def current_level
return 0 unless date_started
def committed_wdays
committed.map do |day|
Date::ABBR_DAYNAMES.index(day.titleize)
end
end
def n_days
((date_started.to_date)..Date.today).count do |date|
committed_wdays.include? date.wday
end - self.real_missed_days
end
case n_days # 1 - 6 represent the different levels
when 0..9
1
when 10..24
2
when 25..44
3
when 45..69
4
when 70..99
5
else
6
end
end
Please let me know if you need further explanation or code (here's the Gist of it).