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