Class: Cloud::InstanceType

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud/instancetype.rb,
lib/cloud/instancetype/version.rb

Overview

Describe a public cloud instance type

Constant Summary collapse

VERSION =
"1.1.0"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, raw_data) ⇒ InstanceType

Returns a new instance of InstanceType.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cloud/instancetype.rb', line 10

def initialize(key, raw_data)
  @key = key
  @name = raw_data["name"]
  @sort_value = raw_data["sort_value"]
  @vcpu_count = raw_data["vcpu_count"]
  @ram_bytes = raw_data["ram_bytes"]
  @ram_si_units = raw_data["ram_si_units"]
  @details = raw_data["details"]
  return unless raw_data["category_key"]

  @category = Cloud::InstanceCategory.new(
    raw_data["category_key"], 
    raw_data["category"]
  )
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



7
8
9
# File 'lib/cloud/instancetype.rb', line 7

def category
  @category
end

#detailsObject (readonly)

Returns the value of attribute details.



7
8
9
# File 'lib/cloud/instancetype.rb', line 7

def details
  @details
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/cloud/instancetype.rb', line 7

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/cloud/instancetype.rb', line 7

def name
  @name
end

#ram_bytesObject (readonly)

Returns the value of attribute ram_bytes.



7
8
9
# File 'lib/cloud/instancetype.rb', line 7

def ram_bytes
  @ram_bytes
end

#ram_si_unitsObject (readonly)

Returns the value of attribute ram_si_units.



7
8
9
# File 'lib/cloud/instancetype.rb', line 7

def ram_si_units
  @ram_si_units
end

#sort_valueObject (readonly)

Returns the value of attribute sort_value.



7
8
9
# File 'lib/cloud/instancetype.rb', line 7

def sort_value
  @sort_value
end

#vcpu_countObject (readonly)

Returns the value of attribute vcpu_count.



7
8
9
# File 'lib/cloud/instancetype.rb', line 7

def vcpu_count
  @vcpu_count
end

Class Method Details

.for(cloud) ⇒ Object



31
32
33
34
35
# File 'lib/cloud/instancetype.rb', line 31

def for(cloud)
  load(rails_vendor_path(cloud))
rescue
  load(rails_config_path(cloud))
end

.load(data_path) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/cloud/instancetype.rb', line 37

def load(data_path)
  raw_collection = get_raw_collection(data_path)
  instance_type_collection_factory(
    raw_collection["instance_types"],
    raw_collection["categories"]
  )
end

Instance Method Details

#<=>(other) ⇒ Object



26
27
28
# File 'lib/cloud/instancetype.rb', line 26

def <=>(other)
  sort_value <=> other.sort_value
end