class AwsPricing::CategoryType
Attributes
allupfront_prepay_1_year[RW]
allupfront_prepay_3_year[RW]
convertible_allupfront_prepay_1_year[RW]
convertible_allupfront_prepay_3_year[RW]
convertible_noupfront_price_per_hour_1_year[RW]
convertible_noupfront_price_per_hour_3_year[RW]
convertible_partialupfront_prepay_1_year[RW]
convertible_partialupfront_prepay_3_year[RW]
convertible_partialupfront_price_per_hour_1_year[RW]
convertible_partialupfront_price_per_hour_3_year[RW]
heavy_prepay_1_year[RW]
heavy_prepay_3_year[RW]
heavy_price_per_hour_1_year[RW]
heavy_price_per_hour_3_year[RW]
instance_type[RW]
light_prepay_1_year[RW]
light_prepay_3_year[RW]
light_price_per_hour_1_year[RW]
light_price_per_hour_3_year[RW]
medium_prepay_1_year[RW]
medium_prepay_3_year[RW]
medium_price_per_hour_1_year[RW]
medium_price_per_hour_3_year[RW]
name[RW]
noupfront_price_per_hour_1_year[RW]
noupfront_price_per_hour_3_year[RW]
ondemand_price_per_hour[RW]
partialupfront_prepay_1_year[RW]
partialupfront_prepay_3_year[RW]
partialupfront_price_per_hour_1_year[RW]
partialupfront_price_per_hour_3_year[RW]
Public Class Methods
new(instance_type=nil, name=nil)
click to toggle source
# File lib/amazon-pricing/definitions/category-type.rb 47 def initialize(instance_type=nil, name=nil) 48 @instance_type = instance_type 49 @name = name 50 end
Public Instance Methods
allupfront_effective_rate_1_year()
click to toggle source
# File lib/amazon-pricing/definitions/category-type.rb 27 def allupfront_effective_rate_1_year 28 (allupfront_prepay_1_year / 365 / 24).round(4) 29 end
allupfront_effective_rate_3_year()
click to toggle source
# File lib/amazon-pricing/definitions/category-type.rb 31 def allupfront_effective_rate_3_year 32 (allupfront_prepay_3_year / 3 / 365 / 24).round(4) 33 end
available?(type_of_instance = :ondemand)
click to toggle source
Returns whether an instance_type
is available. type_of_instance = :ondemand, :light, :medium, :heavy
# File lib/amazon-pricing/definitions/category-type.rb 54 def available?(type_of_instance = :ondemand) 55 not price_per_hour(type_of_instance).nil? 56 end
get_breakeven_month(type_of_instance, term)
click to toggle source
type_of_instance = :ondemand, :light, :medium, :heavy term = :year_1, :year_3, nil
# File lib/amazon-pricing/definitions/category-type.rb 250 def get_breakeven_month(type_of_instance, term) 251 # Some regions and types do not have reserved available 252 ondemand_pph = price_per_hour(:ondemand) 253 reserved_pph = price_per_hour(type_of_instance, term) 254 return nil if ondemand_pph.nil? || reserved_pph.nil? 255 256 on_demand = 0 257 reserved = prepay(type_of_instance, term) 258 return nil if reserved.nil? 259 260 for i in 1..36 do 261 on_demand += ondemand_pph * 24 * 30.4 262 reserved += reserved_pph * 24 * 30.4 263 return i if reserved < on_demand 264 end 265 nil 266 end
noupfront_effective_rate_1_year()
click to toggle source
# File lib/amazon-pricing/definitions/category-type.rb 43 def noupfront_effective_rate_1_year 44 (noupfront_price_per_hour_1_year).round(4) 45 end
partialupfront_effective_rate_1_year()
click to toggle source
# File lib/amazon-pricing/definitions/category-type.rb 35 def partialupfront_effective_rate_1_year 36 (partialupfront_prepay_1_year / 365 / 24 + partialupfront_price_per_hour_1_year).round(4) 37 end
partialupfront_effective_rate_3_year()
click to toggle source
# File lib/amazon-pricing/definitions/category-type.rb 39 def partialupfront_effective_rate_3_year 40 (partialupfront_prepay_3_year / 3 / 365 / 24 + partialupfront_price_per_hour_3_year).round(4) 41 end
prepay(type_of_instance = :ondemand, term = nil)
click to toggle source
type_of_instance = :ondemand, :light, :medium, :heavy term = :year_1, :year_3, nil
# File lib/amazon-pricing/definitions/category-type.rb 60 def prepay(type_of_instance = :ondemand, term = nil) 61 case type_of_instance 62 when :ondemand 63 0 64 when :light 65 if term == :year1 66 @light_prepay_1_year 67 elsif term == :year3 68 @light_prepay_3_year 69 end 70 when :medium 71 if term == :year1 72 @medium_prepay_1_year 73 elsif term == :year3 74 @medium_prepay_3_year 75 end 76 when :heavy 77 if term == :year1 78 @heavy_prepay_1_year 79 elsif term == :year3 80 @heavy_prepay_3_year 81 end 82 when :allupfront 83 if term == :year1 84 @allupfront_prepay_1_year 85 elsif term == :year1_convertible 86 @convertible_allupfront_prepay_1_year 87 elsif term == :year3 88 @allupfront_prepay_3_year 89 elsif term == :year3_convertible 90 @convertible_allupfront_prepay_3_year 91 end 92 when :partialupfront 93 if term == :year1 94 @partialupfront_prepay_1_year 95 elsif term == :year1_convertible 96 @convertible_partialupfront_prepay_1_year 97 elsif term == :year3 98 @partialupfront_prepay_3_year 99 elsif term == :year3_convertible 100 @convertible_partialupfront_prepay_3_year 101 end 102 end 103 end
price_per_hour(type_of_instance = :ondemand, term = nil)
click to toggle source
type_of_instance = :ondemand, :light, :medium, :heavy term = :year1, :year3, nil
# File lib/amazon-pricing/definitions/category-type.rb 154 def price_per_hour(type_of_instance = :ondemand, term = nil) 155 case type_of_instance 156 when :ondemand 157 @ondemand_price_per_hour 158 when :light 159 if term == :year1 160 @light_price_per_hour_1_year 161 elsif term == :year3 162 @light_price_per_hour_3_year 163 end 164 when :medium 165 if term == :year1 166 @medium_price_per_hour_1_year 167 elsif term == :year3 168 @medium_price_per_hour_3_year 169 end 170 when :heavy 171 if term == :year1 172 @heavy_price_per_hour_1_year 173 elsif term == :year3 174 @heavy_price_per_hour_3_year 175 end 176 when :partialupfront 177 if term == :year1 178 @partialupfront_price_per_hour_1_year 179 elsif term == :year1_convertible 180 @convertible_partialupfront_price_per_hour_1_year 181 elsif term == :year3 182 @partialupfront_price_per_hour_3_year 183 elsif term == :year3_convertible 184 @convertible_partialupfront_price_per_hour_3_year 185 end 186 when :noupfront 187 if term == :year1 188 @noupfront_price_per_hour_1_year 189 elsif term == :year1_convertible 190 @convertible_noupfront_price_per_hour_1_year 191 elsif term == :year3 192 @noupfront_price_per_hour_3_year 193 elsif term == :year3_convertible 194 @convertible_noupfront_price_per_hour_3_year 195 end 196 when :allupfront 197 0 198 end 199 end
set_prepay(type_of_instance, term, price)
click to toggle source
type_of_instance = :ondemand, :light, :medium, :heavy term = :year1, :year3, nil
# File lib/amazon-pricing/definitions/category-type.rb 107 def set_prepay(type_of_instance, term, price) 108 case type_of_instance 109 when :light 110 if term == :year1 111 @light_prepay_1_year = price 112 elsif term == :year3 113 @light_prepay_3_year = price 114 end 115 when :medium 116 if term == :year1 117 @medium_prepay_1_year = price 118 elsif term == :year3 119 @medium_prepay_3_year = price 120 end 121 when :heavy 122 if term == :year1 123 @heavy_prepay_1_year = price 124 elsif term == :year3 125 @heavy_prepay_3_year = price 126 end 127 when :allupfront 128 if term == :year1 129 @allupfront_prepay_1_year = price 130 elsif term == :year1_convertible 131 @convertible_allupfront_prepay_1_year = price 132 elsif term == :year3 133 @allupfront_prepay_3_year = price 134 elsif term == :year3_convertible 135 @convertible_allupfront_prepay_3_year = price 136 end 137 when :partialupfront 138 if term == :year1 139 @partialupfront_prepay_1_year = price 140 elsif term == :year1_convertible 141 @convertible_partialupfront_prepay_1_year = price 142 elsif term == :year3 143 @partialupfront_prepay_3_year = price 144 elsif term == :year3_convertible 145 @convertible_partialupfront_prepay_3_year = price 146 end 147 else 148 raise "Unable to set prepay for #{instance_type.api_name} : #{name} : #{type_of_instance} : #{term} to #{price}" 149 end 150 end
set_price_per_hour(type_of_instance, term, price_per_hour)
click to toggle source
type_of_instance = :ondemand, :light, :medium, :heavy term = :year_1, :year_3, nil
# File lib/amazon-pricing/definitions/category-type.rb 203 def set_price_per_hour(type_of_instance, term, price_per_hour) 204 case type_of_instance 205 when :ondemand 206 @ondemand_price_per_hour = price_per_hour 207 when :light 208 if term == :year1 209 @light_price_per_hour_1_year = price_per_hour 210 elsif term == :year3 211 @light_price_per_hour_3_year = price_per_hour 212 end 213 when :medium 214 if term == :year1 215 @medium_price_per_hour_1_year = price_per_hour 216 elsif term == :year3 217 @medium_price_per_hour_3_year = price_per_hour 218 end 219 when :heavy 220 if term == :year1 221 @heavy_price_per_hour_1_year = price_per_hour 222 elsif term == :year3 223 @heavy_price_per_hour_3_year = price_per_hour 224 end 225 when :partialupfront 226 if term == :year1 227 @partialupfront_price_per_hour_1_year = price_per_hour 228 elsif term == :year1_convertible 229 @convertible_partialupfront_price_per_hour_1_year = price_per_hour 230 elsif term == :year3 231 @partialupfront_price_per_hour_3_year = price_per_hour 232 elsif term == :year3_convertible 233 @convertible_partialupfront_price_per_hour_3_year = price_per_hour 234 end 235 when :noupfront 236 if term == :year1 237 @noupfront_price_per_hour_1_year = price_per_hour 238 elsif term == :year1_convertible 239 @convertible_noupfront_price_per_hour_1_year = price_per_hour 240 elsif term == :year3 241 @noupfront_price_per_hour_3_year = price_per_hour 242 elsif term == :year3_convertible 243 @convertible_noupfront_price_per_hour_3_year = price_per_hour 244 end 245 end 246 end