Module: Freemium::Rates

Included in:
Subscription, SubscriptionPlan
Defined in:
lib/freemium/rates.rb

Instance Method Summary collapse

Instance Method Details

#daily_rate(options = {}) ⇒ Object

returns the daily cost of this plan.



5
6
7
# File 'lib/freemium/rates.rb', line 5

def daily_rate(options = {})
  yearly_rate(options) / 365
end

#monthly_rate(options = {}) ⇒ Object

returns the monthly cost of this plan.



19
20
21
22
23
24
25
# File 'lib/freemium/rates.rb', line 19

def monthly_rate(options = {})
  begin
    rate(options)
  rescue
    rate
  end
end

#paid?Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/freemium/rates.rb', line 27

def paid?
  return false unless rate
  rate.cents > 0
end

#yearly_rate(options = {}) ⇒ Object

returns the yearly cost of this plan.



10
11
12
13
14
15
16
# File 'lib/freemium/rates.rb', line 10

def yearly_rate(options = {})
  begin
    rate(options) * 12
  rescue
    rate * 12
  end
end