Class: Ec2spec::OfferFile
- Inherits:
-
Object
- Object
- Ec2spec::OfferFile
- Defined in:
- lib/ec2spec/offer_file.rb
Constant Summary collapse
- OFFER_FILE_URL =
'https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/20180802021534/ap-northeast-1/index.json'- OFFER_FILE_NAME =
'price_list.json'- OFFER_FILE_DIR =
'.ec2spec'
Instance Method Summary collapse
-
#initialize(instance_type) ⇒ OfferFile
constructor
A new instance of OfferFile.
- #price_per_unit ⇒ Object
Constructor Details
#initialize(instance_type) ⇒ OfferFile
Returns a new instance of OfferFile.
10 11 12 13 |
# File 'lib/ec2spec/offer_file.rb', line 10 def initialize(instance_type) @instance_type = instance_type @offer_file_json = nil end |
Instance Method Details
#price_per_unit ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/ec2spec/offer_file.rb', line 15 def price_per_unit sku_instance_type = sku on_demand = offer_file_json['terms']['OnDemand'] sku_value = on_demand[sku_instance_type].first[1] price_dimensions = sku_value['priceDimensions'] price_dimensions.first[1]['pricePerUnit']['USD'].to_f end |