Class: SubscriptionFu::Plan
- Inherits:
-
Object
- Object
- SubscriptionFu::Plan
- Includes:
- ActionView::Helpers::NumberHelper, Comparable
- Defined in:
- app/models/subscription_fu/plan.rb
Constant Summary collapse
- TAX =
0.05
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#price ⇒ Object
Returns the value of attribute price.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #currency ⇒ Object
- #free_plan? ⇒ Boolean
- #human_name ⇒ Object
- #human_price ⇒ Object
-
#initialize(key, price, data = {}) ⇒ Plan
constructor
A new instance of Plan.
- #price_tax ⇒ Object
- #price_with_tax ⇒ Object
Constructor Details
#initialize(key, price, data = {}) ⇒ Plan
Returns a new instance of Plan.
10 11 12 13 14 |
# File 'app/models/subscription_fu/plan.rb', line 10 def initialize(key, price, data = {}) self.key = key self.price = price data.each {|k,v| self.send("#{k}=", v) } end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
7 8 9 |
# File 'app/models/subscription_fu/plan.rb', line 7 def key @key end |
#price ⇒ Object
Returns the value of attribute price.
8 9 10 |
# File 'app/models/subscription_fu/plan.rb', line 8 def price @price end |
Instance Method Details
#<=>(other) ⇒ Object
40 41 42 |
# File 'app/models/subscription_fu/plan.rb', line 40 def <=>(other) price <=> other.price end |
#currency ⇒ Object
36 37 38 |
# File 'app/models/subscription_fu/plan.rb', line 36 def currency "JPY" end |
#free_plan? ⇒ Boolean
24 25 26 |
# File 'app/models/subscription_fu/plan.rb', line 24 def free_plan? price == 0 end |
#human_name ⇒ Object
16 17 18 |
# File 'app/models/subscription_fu/plan.rb', line 16 def human_name I18n.t(key, :scope => [:subscription_fu, :plan, :options]) end |
#human_price ⇒ Object
20 21 22 |
# File 'app/models/subscription_fu/plan.rb', line 20 def human_price number_to_currency(price_with_tax) end |
#price_tax ⇒ Object
32 33 34 |
# File 'app/models/subscription_fu/plan.rb', line 32 def price_tax (price * TAX).to_i end |
#price_with_tax ⇒ Object
28 29 30 |
# File 'app/models/subscription_fu/plan.rb', line 28 def price_with_tax (price * (1.0 + TAX)).to_i end |