Class: Fog::Parsers::XenServer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/xenserver/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



8
9
10
# File 'lib/fog/xenserver/parser.rb', line 8

def initialize
  reset
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/fog/xenserver/parser.rb', line 6

def response
  @response
end

Instance Method Details

#parse(data) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/xenserver/parser.rb', line 16

def parse( data )
  if data.kind_of? Hash
    @response = data.symbolize_keys!
    @response.each do |k,v|
      if @response[k] == "OpaqueRef:NULL"
        @response[k] = nil
      end
    end
  elsif data.kind_of? Array
    @response = data.first
  elsif data.kind_of?(String) and data =~ /OpaqueRef:/
    @response = data
  end
  
  @response
end

#resetObject



12
13
14
# File 'lib/fog/xenserver/parser.rb', line 12

def reset
  @response = {}
end