Class: Joyent::Cloud::Pricing::Reserve
- Inherits:
-
Object
- Object
- Joyent::Cloud::Pricing::Reserve
- Includes:
- Helpers
- Defined in:
- lib/pricing/reserve.rb
Instance Attribute Summary collapse
-
#flavor ⇒ Object
Returns the value of attribute flavor.
-
#monthly ⇒ Object
Returns the value of attribute monthly.
-
#prepay ⇒ Object
Returns the value of attribute prepay.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#years ⇒ Object
Returns the value of attribute years.
Instance Method Summary collapse
-
#initialize(flavor, config) ⇒ Reserve
constructor
A new instance of Reserve.
- #monthly_averaged ⇒ Object
- #monthly_discount ⇒ Object
- #monthly_discount_percent ⇒ Object
- #monthly_full_price ⇒ Object
- #to_hash ⇒ Object
- #total_discount ⇒ Object
- #total_payout ⇒ Object
Methods included from Helpers
#currency_format, #monthly_from_hourly
Constructor Details
#initialize(flavor, config) ⇒ Reserve
Returns a new instance of Reserve.
7 8 9 10 11 12 13 |
# File 'lib/pricing/reserve.rb', line 7 def initialize(flavor, config) @flavor = flavor.to_sym @prepay = config[:prepay].to_f @monthly = config[:monthly].to_f @quantity = config[:quantity].to_i @years = config[:years] end |
Instance Attribute Details
#flavor ⇒ Object
Returns the value of attribute flavor.
5 6 7 |
# File 'lib/pricing/reserve.rb', line 5 def flavor @flavor end |
#monthly ⇒ Object
Returns the value of attribute monthly.
5 6 7 |
# File 'lib/pricing/reserve.rb', line 5 def monthly @monthly end |
#prepay ⇒ Object
Returns the value of attribute prepay.
5 6 7 |
# File 'lib/pricing/reserve.rb', line 5 def prepay @prepay end |
#quantity ⇒ Object
Returns the value of attribute quantity.
5 6 7 |
# File 'lib/pricing/reserve.rb', line 5 def quantity @quantity end |
#years ⇒ Object
Returns the value of attribute years.
5 6 7 |
# File 'lib/pricing/reserve.rb', line 5 def years @years end |
Instance Method Details
#monthly_averaged ⇒ Object
15 16 17 |
# File 'lib/pricing/reserve.rb', line 15 def monthly_averaged (total_payout / (@years * 12)).round(2) end |
#monthly_discount ⇒ Object
27 28 29 |
# File 'lib/pricing/reserve.rb', line 27 def monthly_discount (total_discount / 12 / years).round(2) end |
#monthly_discount_percent ⇒ Object
31 32 33 |
# File 'lib/pricing/reserve.rb', line 31 def monthly_discount_percent (100 * monthly_discount / monthly_full_price).round(2) end |
#monthly_full_price ⇒ Object
35 36 37 |
# File 'lib/pricing/reserve.rb', line 35 def monthly_full_price pricing.monthly flavor end |
#to_hash ⇒ Object
39 40 41 |
# File 'lib/pricing/reserve.rb', line 39 def to_hash {prepay: prepay, monthly: monthly, years: years, quantity: quantity} end |
#total_discount ⇒ Object
23 24 25 |
# File 'lib/pricing/reserve.rb', line 23 def total_discount (monthly_full_price * 12 * years).round(2) - total_payout end |
#total_payout ⇒ Object
19 20 21 |
# File 'lib/pricing/reserve.rb', line 19 def total_payout (@prepay + @years * 12 * @monthly).round(2) end |