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.



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

def initialize
  reset
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#parse(data) ⇒ Object



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

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



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

def reset
  @response = {}
end