Module: HardwareProfilesHelper

Defined in:
lib/deltacloud/helpers/hardware_profiles_helper.rb

Instance Method Summary collapse

Instance Method Details

#format_hardware_property(prop) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/deltacloud/helpers/hardware_profiles_helper.rb', line 3

def format_hardware_property(prop)
  return "∅" unless prop
  u = hardware_property_unit(prop)
  case prop.kind
    when :range
    "#{prop.first} #{u} - #{prop.last} #{u} (default: #{prop.default} #{u})"
    when :enum
    prop.values.collect{ |v| "#{v} #{u}"}.join(', ') + " (default: #{prop.default} #{u})"
    else
    "#{prop.value} #{u}"
  end
end

#format_instance_profile(ip) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/deltacloud/helpers/hardware_profiles_helper.rb', line 16

def format_instance_profile(ip)
  o = ip.overrides.collect do |p, v|
    u = hardware_property_unit(p)
    "#{p} = #{v} #{u}"
  end
  if o.empty?
    ""
  else
    "with #{o.join(", ")}"
  end
end