habitica/app/models/habit.rb

16 lines
384 B
Ruby
Raw Normal View History

2012-02-01 04:09:00 +00:00
class Habit < ActiveRecord::Base
ALWAYS = 1
DAILY = 2
ONE_TIME = 3
belongs_to :user
2012-02-01 15:03:27 +00:00
def vote(direction)
next_vote = 1 #TODO return log or linear based on current score
next_vote *= -1 if(direction=='down')
self.score += next_vote
self.votedate = Time.now
#TODO if type=daily & votedate=today, set done back to false (have a done column?)
end
2012-02-01 04:09:00 +00:00
end