Class: AwsPricing::Region

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

Overview

Region represents a geographic area in which Amazon Web Services has one or more data centers. Different regions will offer difference services and pricing.

e.g. us-east, us-west

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Region


20
21
22
23
24
# File 'lib/amazon-pricing/region.rb', line 20

def initialize(name)
  @name = name
  @ec2_instance_types = {}
  @rds_instance_types = {}
end

Instance Attribute Details

#ebs_priceObject

Returns the value of attribute ebs_price


18
19
20
# File 'lib/amazon-pricing/region.rb', line 18

def ebs_price
  @ebs_price
end

#ec2_instance_typesObject

Returns the value of attribute ec2_instance_types


18
19
20
# File 'lib/amazon-pricing/region.rb', line 18

def ec2_instance_types
  @ec2_instance_types
end

#nameObject

Returns the value of attribute name


18
19
20
# File 'lib/amazon-pricing/region.rb', line 18

def name
  @name
end

#rds_instance_typesObject

Returns the value of attribute rds_instance_types


18
19
20
# File 'lib/amazon-pricing/region.rb', line 18

def rds_instance_types
  @rds_instance_types
end

Instance Method Details

#add_or_update_ec2_instance_type(api_name, name) ⇒ Object

type_of_instance = :ondemand, :light, :medium, :heavy


49
50
51
52
53
54
55
56
# File 'lib/amazon-pricing/region.rb', line 49

def add_or_update_ec2_instance_type(api_name, name)
  current = get_ec2_instance_type(api_name)
  if current.nil?
    current = Ec2InstanceType.new(self, api_name, name)
    @ec2_instance_types[api_name] = current
  end
  current
end

#add_or_update_rds_instance_type(api_name, name) ⇒ Object


58
59
60
61
62
63
64
65
# File 'lib/amazon-pricing/region.rb', line 58

def add_or_update_rds_instance_type(api_name, name)
  current = get_rds_instance_type(api_name)
  if current.nil?
    current = RdsInstanceType.new(self, api_name, name)
    @rds_instance_types[api_name] = current
  end
  current
end

#get_ec2_instance_type(api_name) ⇒ Object


72
73
74
# File 'lib/amazon-pricing/region.rb', line 72

def get_ec2_instance_type(api_name)
  @ec2_instance_types[api_name]
end

#get_instance_type(api_name) ⇒ Object

Maintained for backward compatibility reasons (retrieves EC2 instance type)


68
69
70
# File 'lib/amazon-pricing/region.rb', line 68

def get_instance_type(api_name)
  get_ec2_instance_type(api_name)
end

#get_rds_instance_type(api_name) ⇒ Object


76
77
78
# File 'lib/amazon-pricing/region.rb', line 76

def get_rds_instance_type(api_name)
  @rds_instance_types[api_name]
end

#instance_type_available?(api_name, type_of_instance = :ondemand, operating_system = :linux) ⇒ Boolean

Returns whether an instance_type is available. operating_system = :linux, :mswin, :rhel, :sles, :mswinSQL, :mswinSQLWeb type_of_instance = :ondemand, :light, :medium, :heavy


42
43
44
45
46
# File 'lib/amazon-pricing/region.rb', line 42

def instance_type_available?(api_name, type_of_instance = :ondemand, operating_system = :linux)
  instance = @ec2_instance_types[api_name]
  return false if instance.nil?
  instance.available?(type_of_instance, operating_system)
end

#instance_typesObject

Maintained for backward compatibility reasons (retrieves EC2 instance type)


27
28
29
# File 'lib/amazon-pricing/region.rb', line 27

def instance_types
  ec2_instance_types
end