Class: Tang::Plan

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/tang/plan.rb

Constant Summary collapse

INTERVALS =
['day', 'week', 'month', 'year']

Instance Method Summary collapse

Instance Method Details

#interval_countObject



39
40
41
# File 'app/models/tang/plan.rb', line 39

def interval_count
  self[:interval_count] || 1
end

#period_days_from(date) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'app/models/tang/plan.rb', line 28

def period_days_from(date)
  if interval == 'week'
    return date + interval_count.weeks
  elsif interval == 'month'
    return date + interval_count.months
  elsif interval == 'year'
    return date + interval_count.years
  end
  return date + interval_count.days
end