Class: AWSCosts::EBS

Inherits:
Object
  • Object
show all
Defined in:
lib/awscosts/ec2_ebs.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ EBS

Returns a new instance of EBS.



5
6
7
# File 'lib/awscosts/ec2_ebs.rb', line 5

def initialize data
  @data= data
end

Class Method Details

.fetch(region) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/awscosts/ec2_ebs.rb', line 13

def self.fetch region
  transformed = AWSCosts::Cache.get_jsonp('/pricing/1/ebs/pricing-ebs.min.js') do |data|
    result = {}
    data['config']['regions'].each do |r|
      result[r['region']] = r['types']
    end
    result
  end
  self.new(transformed[region])
end

Instance Method Details

#price(type = nil) ⇒ Object



9
10
11
# File 'lib/awscosts/ec2_ebs.rb', line 9

def price type = nil
  type.nil? ? @data : @data[type]
end