Class: AwsPricing::EbsPrice

Inherits:
Object
  • Object
show all
Defined in:
lib/amazon-pricing/ebs-price.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(region) ⇒ EbsPrice


17
18
19
# File 'lib/amazon-pricing/ebs-price.rb', line 17

def initialize(region)
  #@region = region
end

Instance Attribute Details

#preferred_per_gbObject

Returns the value of attribute preferred_per_gb


13
14
15
# File 'lib/amazon-pricing/ebs-price.rb', line 13

def preferred_per_gb
  @preferred_per_gb
end

#preferred_per_iopsObject

Returns the value of attribute preferred_per_iops


13
14
15
# File 'lib/amazon-pricing/ebs-price.rb', line 13

def preferred_per_iops
  @preferred_per_iops
end

#s3_snaps_per_gbObject

Returns the value of attribute s3_snaps_per_gb


13
14
15
# File 'lib/amazon-pricing/ebs-price.rb', line 13

def s3_snaps_per_gb
  @s3_snaps_per_gb
end

#ssd_per_gbObject

Returns the value of attribute ssd_per_gb


13
14
15
# File 'lib/amazon-pricing/ebs-price.rb', line 13

def ssd_per_gb
  @ssd_per_gb
end

#standard_per_gbObject

Returns the value of attribute standard_per_gb


13
14
15
# File 'lib/amazon-pricing/ebs-price.rb', line 13

def standard_per_gb
  @standard_per_gb
end

#standard_per_million_ioObject

Returns the value of attribute standard_per_million_io


13
14
15
# File 'lib/amazon-pricing/ebs-price.rb', line 13

def standard_per_million_io
  @standard_per_million_io
end

Instance Method Details

#update_from_json(json) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/amazon-pricing/ebs-price.rb', line 22

def update_from_json(json)
  json["types"].each do |t|
    case t["name"]
    when "Amazon EBS Magnetic volumes"
      @standard_per_gb = t["values"].select{|v| v["rate"] == "perGBmoProvStorage" }.first["prices"].values.first.to_f
      @standard_per_million_io = t["values"].select{|v| v["rate"] == "perMMIOreq" }.first["prices"].values.first.to_f
    when "Amazon EBS Provisioned IOPS (SSD) volumes"
      @preferred_per_gb = t["values"].select{|v| v["rate"] == "perGBmoProvStorage" }.first["prices"].values.first.to_f
      @preferred_per_iops = t["values"].select{|v| v["rate"] == "perPIOPSreq" }.first["prices"].values.first.to_f
    when "Amazon EBS General Purpose (SSD) volumes"
      @ssd_per_gb = t["values"].select{|v| v["rate"] == "perGBmoProvStorage" }.first["prices"].values.first.to_f
    when "ebsSnapsToS3"
      @s3_snaps_per_gb = t["values"].select{|v| v["rate"] == "perGBmoDataStored" }.first["prices"].values.first.to_f
    end
  end
end