Class: Netscaler::Server::ServiceInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/netscaler/server/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_response, index) ⇒ ServiceInfo

Returns a new instance of ServiceInfo.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/netscaler/server/response.rb', line 52

def initialize(raw_response, index)
  @name = raw_response[:servicename][:item]
  @ip_address = raw_response[:serviceipaddress][:item]
  @state = raw_response[:svrstate][:item]
  @port = raw_response[:port][:item]
  @type = raw_response[:servicetype][:item]

  if !index.nil?
    @name = @name[index]
    @ip_address = @ip_address[index]
    @state = @state[index]
    @port = @port[index]
    @type = @type[index]
  end

  @servicegroup = if raw_response[:servicegroupname] && raw_response[:servicegroupname][:item]
                    ServiceGroupInfo.new(raw_response, index)
                  else
                    nil
                  end
end

Instance Attribute Details

#ip_addressObject (readonly)

Returns the value of attribute ip_address.



50
51
52
# File 'lib/netscaler/server/response.rb', line 50

def ip_address
  @ip_address
end

#nameObject (readonly)

Returns the value of attribute name.



50
51
52
# File 'lib/netscaler/server/response.rb', line 50

def name
  @name
end

#servicegroupObject (readonly)

Returns the value of attribute servicegroup.



50
51
52
# File 'lib/netscaler/server/response.rb', line 50

def servicegroup
  @servicegroup
end

#stateObject (readonly)

Returns the value of attribute state.



50
51
52
# File 'lib/netscaler/server/response.rb', line 50

def state
  @state
end

#typeObject (readonly)

Returns the value of attribute type.



50
51
52
# File 'lib/netscaler/server/response.rb', line 50

def type
  @type
end

Instance Method Details

#portObject



74
75
76
# File 'lib/netscaler/server/response.rb', line 74

def port
  @port.to_i
end

#to_hashObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/netscaler/server/response.rb', line 78

def to_hash
  hash = {
    :name => name,
    :ip_address => ip_address,
    :type => type,
    :state => state,
    :port => port,
  }

  if servicegroup
    hash[:servicegroup] = servicegroup.to_hash
  end

  hash
end