Class: Ec2spec::HostResult
- Inherits:
-
Object
- Object
- Ec2spec::HostResult
- Defined in:
- lib/ec2spec/host_result.rb
Constant Summary collapse
- MONTH_OF_DAYS =
31
- NA_VALUE =
'N/A'
- NUMBER_OF_DECIMAL_PLACES =
3
- LABEL_WITH_METHODS =
{ 'instance_type' => :instance_type, 'instance_id' => :instance_id, 'vCPU' => :vcpu, 'memory' => :memory, 'price (USD/H)' => :price_per_unit, 'price (USD/M)' => :price_per_month, }
Instance Attribute Summary collapse
-
#backend ⇒ Object
Returns the value of attribute backend.
-
#host ⇒ Object
Returns the value of attribute host.
-
#instance_id ⇒ Object
Returns the value of attribute instance_id.
-
#instance_type ⇒ Object
Returns the value of attribute instance_type.
- #price_per_unit ⇒ Object
- #vcpu ⇒ Object
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(region, host, days = nil) ⇒ HostResult
constructor
A new instance of HostResult.
- #memory ⇒ Object
- #na_values ⇒ Object
- #price_per_currency_unit ⇒ Object
- #price_per_currency_unit_month ⇒ Object
- #price_per_month ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(region, host, days = nil) ⇒ HostResult
Returns a new instance of HostResult.
29 30 31 32 33 34 |
# File 'lib/ec2spec/host_result.rb', line 29 def initialize(region, host, days = nil) @region = region @host = host @backend = nil @days = days || MONTH_OF_DAYS end |
Instance Attribute Details
#backend ⇒ Object
Returns the value of attribute backend.
16 17 18 |
# File 'lib/ec2spec/host_result.rb', line 16 def backend @backend end |
#host ⇒ Object
Returns the value of attribute host.
16 17 18 |
# File 'lib/ec2spec/host_result.rb', line 16 def host @host end |
#instance_id ⇒ Object
Returns the value of attribute instance_id.
16 17 18 |
# File 'lib/ec2spec/host_result.rb', line 16 def instance_id @instance_id end |
#instance_type ⇒ Object
Returns the value of attribute instance_type.
17 18 19 |
# File 'lib/ec2spec/host_result.rb', line 17 def instance_type @instance_type end |
Class Method Details
.label_with_methods ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/ec2spec/host_result.rb', line 20 def self.label_with_methods label_methods = LABEL_WITH_METHODS if PriceCalculator.instance.currency_values? label_methods['price (%s/H)'] = :price_per_currency_unit label_methods['price (%s/M)'] = :price_per_currency_unit_month end label_methods end |
Instance Method Details
#memory ⇒ Object
56 57 58 59 |
# File 'lib/ec2spec/host_result.rb', line 56 def memory @memory ||= Ec2spec::OfferFile.instance.memory(@instance_type) end |
#na_values ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/ec2spec/host_result.rb', line 36 def na_values @instance_type = NA_VALUE @instance_id = NA_VALUE @memory = NA_VALUE @vcpu = NA_VALUE @price_per_unit = NA_VALUE end |
#price_per_currency_unit ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/ec2spec/host_result.rb', line 66 def price_per_currency_unit return @price_per_currency_unit unless @price_per_currency_unit.nil? dollar_price = Ec2spec::OfferFile.instance.price_per_unit(@instance_type) @price_per_currency_unit = PriceCalculator .instance.currency_unit_price(dollar_price) @price_per_currency_unit.fractional.floor(NUMBER_OF_DECIMAL_PLACES).to_f end |
#price_per_currency_unit_month ⇒ Object
80 81 82 83 84 |
# File 'lib/ec2spec/host_result.rb', line 80 def price_per_currency_unit_month return NA_VALUE if @price_per_currency_unit == NA_VALUE (@price_per_currency_unit * 24 * @days) .fractional.floor(NUMBER_OF_DECIMAL_PLACES).to_f end |
#price_per_month ⇒ Object
75 76 77 78 |
# File 'lib/ec2spec/host_result.rb', line 75 def price_per_month return NA_VALUE if @price_per_unit == NA_VALUE @price_per_unit * 24 * @days end |
#to_hash ⇒ Object
86 87 88 |
# File 'lib/ec2spec/host_result.rb', line 86 def to_hash host_values end |