Class: InstanceAddress
- Inherits:
-
Object
- Object
- InstanceAddress
- Defined in:
- lib/deltacloud/models/instance_address.rb
Overview
Model to store the hardware profile applied to an instance together with any instance-specific overrides
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#address_type ⇒ Object
Returns the value of attribute address_type.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(address, opts = {}) ⇒ InstanceAddress
constructor
A new instance of InstanceAddress.
- #is_hostname? ⇒ Boolean
- #is_ipv4? ⇒ Boolean
- #is_ipv6? ⇒ Boolean
- #is_mac? ⇒ Boolean
- #is_vnc? ⇒ Boolean
- #to_hash(context) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(address, opts = {}) ⇒ InstanceAddress
Returns a new instance of InstanceAddress.
24 25 26 27 28 29 |
# File 'lib/deltacloud/models/instance_address.rb', line 24 def initialize(address, opts={}) self.address = address self.port = opts[:port] if opts[:port] self.address_type = opts[:type] || :ipv4 self end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
20 21 22 |
# File 'lib/deltacloud/models/instance_address.rb', line 20 def address @address end |
#address_type ⇒ Object
Returns the value of attribute address_type.
22 23 24 |
# File 'lib/deltacloud/models/instance_address.rb', line 22 def address_type @address_type end |
#port ⇒ Object
Returns the value of attribute port.
21 22 23 |
# File 'lib/deltacloud/models/instance_address.rb', line 21 def port @port end |
Instance Method Details
#is_hostname? ⇒ Boolean
61 62 63 |
# File 'lib/deltacloud/models/instance_address.rb', line 61 def is_hostname? address_type == :hostname end |
#is_ipv4? ⇒ Boolean
53 54 55 |
# File 'lib/deltacloud/models/instance_address.rb', line 53 def is_ipv4? address_type == :ipv4 end |
#is_ipv6? ⇒ Boolean
57 58 59 |
# File 'lib/deltacloud/models/instance_address.rb', line 57 def is_ipv6? address_type == :ipv6 end |
#is_mac? ⇒ Boolean
49 50 51 |
# File 'lib/deltacloud/models/instance_address.rb', line 49 def is_mac? address_type == :mac end |
#is_vnc? ⇒ Boolean
65 66 67 |
# File 'lib/deltacloud/models/instance_address.rb', line 65 def is_vnc? address_type == :vnc end |
#to_hash(context) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/deltacloud/models/instance_address.rb', line 40 def to_hash(context) r = { :address => address, :type => address_type } r.merge!(:port => port) if !port.nil? r end |
#to_s ⇒ Object
35 36 37 38 |
# File 'lib/deltacloud/models/instance_address.rb', line 35 def to_s return ['VNC', address, port].join(':') if is_vnc? address end |