Class: Ec2spec::PriceCalculator
- Inherits:
-
Object
- Object
- Ec2spec::PriceCalculator
- Includes:
- Singleton
- Defined in:
- lib/ec2spec/price_calculator.rb
Constant Summary collapse
- PRICE_CALCULATORS =
{ manual: Calculator::ManualPriceCalculator, api: Calculator::ApiPriceCalculator, }
Instance Attribute Summary collapse
-
#currency_unit ⇒ Object
Returns the value of attribute currency_unit.
-
#dollar_exchange_rate ⇒ Object
Returns the value of attribute dollar_exchange_rate.
Instance Method Summary collapse
- #currency_values? ⇒ Boolean
-
#initialize ⇒ PriceCalculator
constructor
A new instance of PriceCalculator.
- #prepare(unit, rate, calc_type = :manual, app_id = nil) ⇒ Object
Constructor Details
#initialize ⇒ PriceCalculator
Returns a new instance of PriceCalculator.
19 20 21 22 23 |
# File 'lib/ec2spec/price_calculator.rb', line 19 def initialize @currency_unit = nil @dollar_exchange_rate = nil @app_id = nil end |
Instance Attribute Details
#currency_unit ⇒ Object
Returns the value of attribute currency_unit.
12 13 14 |
# File 'lib/ec2spec/price_calculator.rb', line 12 def currency_unit @currency_unit end |
#dollar_exchange_rate ⇒ Object
Returns the value of attribute dollar_exchange_rate.
12 13 14 |
# File 'lib/ec2spec/price_calculator.rb', line 12 def dollar_exchange_rate @dollar_exchange_rate end |
Instance Method Details
#currency_values? ⇒ Boolean
39 40 41 |
# File 'lib/ec2spec/price_calculator.rb', line 39 def currency_values? !@currency_unit.nil? end |
#prepare(unit, rate, calc_type = :manual, app_id = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ec2spec/price_calculator.rb', line 25 def prepare(unit, rate, calc_type = :manual, app_id = nil) @currency_unit = unit @dollar_exchange_rate = rate @app_id = app_id @calc_type = calc_type extend_calc Money.infinite_precision = true raise ApiKeyError if calc_type_sym == :api && app_id.nil? prepare_exchange_api(app_id) if calc_type_sym == :api self end |