Class: Netscaler::ServiceGroup::Response
- Inherits:
-
Object
- Object
- Netscaler::ServiceGroup::Response
- Defined in:
- lib/netscaler/servicegroup/response.rb
Instance Method Summary collapse
-
#initialize(raw_response) ⇒ Response
constructor
A new instance of Response.
- #name ⇒ Object
- #servers ⇒ Object
- #state ⇒ Object
- #to_hash ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(raw_response) ⇒ Response
Returns a new instance of Response.
3 4 5 |
# File 'lib/netscaler/servicegroup/response.rb', line 3 def initialize(raw_response) @info = raw_response[:return][:list][:item] end |
Instance Method Details
#name ⇒ Object
7 8 9 |
# File 'lib/netscaler/servicegroup/response.rb', line 7 def name @info[:servicegroupname] end |
#servers ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/netscaler/servicegroup/response.rb', line 19 def servers @parsed_servers ||= [] return @parsed_servers if !@parsed_servers.empty? || @info[:servername].nil? if @info[:servername][:item].is_a?(String) @parsed_servers << ServerInfo.new(@info, nil) else @info[:servername][:item].each_with_index do |name, i| @parsed_servers << ServerInfo.new(@info, i) end end @parsed_servers end |
#state ⇒ Object
11 12 13 |
# File 'lib/netscaler/servicegroup/response.rb', line 11 def state @info[:state] end |
#to_hash ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/netscaler/servicegroup/response.rb', line 34 def to_hash hash = { :name => name, :state => state, :type => type, } if !servers.empty? hash[:servers] = servers.map {|s| s.to_hash} end hash end |
#type ⇒ Object
15 16 17 |
# File 'lib/netscaler/servicegroup/response.rb', line 15 def type @info[:servicetype] end |