Class: AWSCosts::ELB

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ELB

Returns a new instance of ELB.



3
4
5
# File 'lib/awscosts/ec2_elb.rb', line 3

def initialize data
  @data= data
end

Class Method Details

.fetch(region) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/awscosts/ec2_elb.rb', line 15

def self.fetch region
  transformed = AWSCosts::Cache.get_jsonp('/pricing/1/ec2/pricing-elb.min.js') do |data|
    result = {}
    data['config']['regions'].each do |r|
      container = {}
      r['types'].each do |type|
        type['values'].each do |value|
          container[value['rate']] = value['prices']['USD'].to_f
        end
      end
      result[r['region']] = container
    end
    result
  end
  self.new(transformed[region])
end

Instance Method Details

#price_per_gbObject



11
12
13
# File 'lib/awscosts/ec2_elb.rb', line 11

def price_per_gb
  @data['perGBProcessed']
end

#price_per_hourObject



7
8
9
# File 'lib/awscosts/ec2_elb.rb', line 7

def price_per_hour
  @data['perELBHour']
end