Class: Deltacloud::InstanceAddress

Inherits:
Object
  • Object
show all
Defined in:
lib/deltacloud/models/instance_address.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address, opts = {}) ⇒ InstanceAddress

Returns a new instance of InstanceAddress.



25
26
27
28
29
30
# File 'lib/deltacloud/models/instance_address.rb', line 25

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

#addressObject

Returns the value of attribute address.



21
22
23
# File 'lib/deltacloud/models/instance_address.rb', line 21

def address
  @address
end

#address_typeObject

Returns the value of attribute address_type.



23
24
25
# File 'lib/deltacloud/models/instance_address.rb', line 23

def address_type
  @address_type
end

#portObject

Returns the value of attribute port.



22
23
24
# File 'lib/deltacloud/models/instance_address.rb', line 22

def port
  @port
end

Instance Method Details

#is_hostname?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/deltacloud/models/instance_address.rb', line 62

def is_hostname?
  address_type == :hostname
end

#is_ipv4?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/deltacloud/models/instance_address.rb', line 54

def is_ipv4?
  address_type == :ipv4
end

#is_ipv6?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/deltacloud/models/instance_address.rb', line 58

def is_ipv6?
  address_type == :ipv6
end

#is_mac?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/deltacloud/models/instance_address.rb', line 50

def is_mac?
  address_type == :mac
end

#is_vnc?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/deltacloud/models/instance_address.rb', line 66

def is_vnc?
  address_type == :vnc
end

#to_hash(context) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/deltacloud/models/instance_address.rb', line 41

def to_hash(context)
  r = {
    :address => address,
    :type => address_type
  }
  r.merge!(:port => port) if !port.nil?
  r
end

#to_sObject



36
37
38
39
# File 'lib/deltacloud/models/instance_address.rb', line 36

def to_s
  return ['VNC', address, port].join(':') if is_vnc?
  address
end